Skip to content

About

JDBC ORM provider for the Apache IoTDB Tree model with Spring Boot auto-configuration

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

IoTDB Tree ORM

English | 中文

A JDBC ORM provider for the IoTDB Tree data model that generates Tree SQL, binds named parameters, maps query results to Java fields and ships a Spring Boot auto-configuration.

CI

What it does

  • Builds Tree-model statements (select ... from <device>, insert into <device>) and executes them with TreeModel over a pooled JDBC connection.
  • Expands #{name} placeholders into JDBC placeholders with TreeStatementGenerator, binds arguments, expands collections and turns an empty collection into NULL.
  • Maps result columns onto TreeEntity subclasses; a ts, time or timestamp field carries the timestamp and non-null fields become measurements.
  • Validates Tree rules before execution: no table-prefix or tag inserts, no ordering by non-time columns, one interval plus start and end time for window queries.

Compatibility

IoTDB version Data model Protocol JDK
2.x Tree JDBC (jdbc:iotdb://<host>:6667/, iotdb-jdbc 2.0.6) Java 8 or newer
  • Spring Boot 2.3.7 auto-configuration is optional: the provider works as a plain library through TreeModel, TreeQuery and TreeStatementGenerator.
  • HikariCP 3.4.5 provides the connection pool; all settings live under the treeorm prefix.

Build

Prerequisites: a JDK 8 or newer and Maven 3.8 or newer. CI builds with Temurin 8.

git clone https://github.com/iotdb-ecosystem/iotdb-tree-orm.git
cd iotdb-tree-orm
mvn -B -ntp verify

The build produces target/iotdb-tree-orm-1.0.0.jar.

Test

mvn -B -ntp verify

Ten unit tests cover SQL generation, named-parameter expansion, entity mapping and connection pooling defaults; no IoTDB instance is needed, and this is exactly the command CI runs. The claims about the Tree model are verified against the generated SQL, not against a live server.

Configuration

Key Default Meaning
treeorm.url jdbc:iotdb://127.0.0.1:6667/ JDBC endpoint
treeorm.database empty Database path used for short device paths
treeorm.username, treeorm.password root, root Server credentials
treeorm.driverClassName org.apache.iotdb.jdbc.IoTDBDriver JDBC driver
treeorm.minimumIdle 1 Minimum pool size
treeorm.maximumPoolSize 10 Maximum pool size
treeorm.connectionTimeout 3000 Connection timeout in milliseconds
treeorm.maxLifetime, treeorm.idleTimeout 0 Pool lifetimes in milliseconds
treeorm:
  url: jdbc:iotdb://127.0.0.1:6667/
  database: root.factory
  username: root
  password: root
  minimumIdle: 1
  maximumPoolSize: 10
  connectionTimeout: 3000

Usage

public class Reading extends TreeEntity {
    public Long ts;
    public Double temperature;

    public Reading() { }
}

TreeQuery query = TreeQuery.builder()
    .devicePath("sensor_01")
    .startTime(1_700_000_000_000L)
    .endTime(1_700_000_060_000L)
    .orderBy(new String[] {"time"})
    .limit(100)
    .build();

List<Reading> readings = treeModel.executeQuery(Reading.class, query);

A device path below the configured database is resolved relative to it, a full root.* path is used as is. Arbitrary groupBy clauses and ordering by non-time columns are rejected before SQL is executed.

Project status

Upstream candidate. Intended for apache/iotdb-extras; maintainers of apache/iotdb-extras are welcome to adopt this code — open an issue and we will transfer or co-maintain it.

License

Apache-2.0. See LICENSE.

About

JDBC ORM provider for the Apache IoTDB Tree model with Spring Boot auto-configuration

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages