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.
- Builds Tree-model statements (
select ... from <device>,insert into <device>) and executes them withTreeModelover a pooled JDBC connection. - Expands
#{name}placeholders into JDBC placeholders withTreeStatementGenerator, binds arguments, expands collections and turns an empty collection intoNULL. - Maps result columns onto
TreeEntitysubclasses; ats,timeortimestampfield 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.
| 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,TreeQueryandTreeStatementGenerator. - HikariCP 3.4.5 provides the connection pool; all settings live under the
treeormprefix.
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 verifyThe build produces target/iotdb-tree-orm-1.0.0.jar.
mvn -B -ntp verifyTen 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.
| 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: 3000public 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.
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.
Apache-2.0. See LICENSE.