https://github.com/y1j2x34/spring-influxdb-orm
Spring InfluxDB ORM
https://github.com/y1j2x34/spring-influxdb-orm
influxdb orm-framework orm-library spring spring-boot
Last synced: 8 days ago
JSON representation
Spring InfluxDB ORM
- Host: GitHub
- URL: https://github.com/y1j2x34/spring-influxdb-orm
- Owner: y1j2x34
- License: mit
- Created: 2017-10-25T15:42:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-26T10:08:19.000Z (almost 2 years ago)
- Last Synced: 2025-04-15T06:56:49.355Z (8 days ago)
- Topics: influxdb, orm-framework, orm-library, spring, spring-boot
- Language: Java
- Homepage:
- Size: 172 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# spring-influxdb-orm
[](https://travis-ci.org/y1j2x34/spring-influxdb-orm)
[](https://codecov.io/github/y1j2x34/spring-influxdb-orm)## Usages
### Basic Usages
ApplicationContext.xml
```xml
```
CensusMeasurement.java
```java
package com.yourcompany.influxdb.entity;@InfluxDBMeasurement('census')
public class CensusMeasurement implements Serializable {
private static final long serialVersionUID = 8260424450884444916L;private Date time;
@TagColumn("location")
private String location;
@TagColumn("scientist")
private String scientist;@FieldColumn("butterflies")
private Integer butterflies;
@FieldColumn("honeybees")
private Integer honeybees;// getters and setters
// hashCode and equalspublic String toString(){
return "[time: " + time.getTime() + ", location: " + location
+ ", scientist: " + scientist + ", butterflies: " + butterflies + ", honeybees: " + honeybees + "]";
}
}
```CensusDao.java
```java
package com.yourcompany.influxdb.dao;public interface CensusDao extends InfluxDBDao {
@InfluxDBSelect("select * from census where scientist = #{scientist}")
public List selectByScientist(@InfluxDBParam("scientist") String scientist);@InfluxDBExecute("DROP SERIES FROM census where scientist=#{scientist} and location=#{location}")
public void dropSeries( //
@InfluxDBParam("scientist") String scientist, //
@InfluxDBParam("location") Integer location //
);
@InfluxDBSelect("select scientist,location,butterflies from census where scientist = #{scientist}")
public List> selectButterflies( //
@InfluxDBParam("scientist") String scientist, //
@InfluxDBParam("location") Integer location //
);public void hello();
}
```Main.java
```java
package com.yourcompany.influxdb;
public class Main {
public static void main(String[] args) {
try (ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml")) {
context.refresh();
CensusDao dao = context.getBean(CensusDao.class);
List measurements = dao.selectByScientist("lanstroth");
System.out.println(measurements);dao.dropSeries("lastroth", 12);
List> result = dao.selectButterflies("lanstroth", 10);
System.out.println(result);
}
}
}
```## Advanced Usages
### Sharding
```java
// TODO
```### Specify executor
```java
// CensusDao.java
public interface CensusDao{
@SpecifiedExecutor(HelloWorldExecutor.class)
public void execute(String scientist, Integer location);
}
// HelloWorldExecutor.java
public class HelloWorldExecutor extends Executor {
public HelloWorldExecutor(InfluxDBRepository repository) {
super(repository);
}@Override
public ResultContext execute(MapperMethod method, Map parameters) {
System.out.println("hello world");
return ResultContext.VOID;
}
}```
### Custom annotation
Select.java
```java
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@AnnotateExecutor(SelectExecutor.class)
public @interface Select{
String value();
}
```SelectExecutor.java
```java
public class SelectExecutor extends AnnotationExecutor {
public SelectExecutor(InfluxDBRepository repository, Select selectAnnotation) {
super(repository, selectAnnotation);
}@Override
public ResultContext execute(MapperMethod method, Map parameters) {
String command = super.annotation.value();
String parsedCommand = CommandUtils.parseCommand(command, parameters);
return repository.query(parsedCommand);
}
}
```### Gzip support
https://github.com/influxdata/influxdb-java#gzips-support-version-25-required
## License
This project is released under MIT License