Sorm4j
https://scrapbox.io/files/605ad264b3914c001c745c8d.png
Overview
Sorm4j (Simple micro Object-Relation Mapper for Java) is a Java-based micro-ORM tool that could access a database in a oneliner. Sorm4j is a sort of JDBC wrapper. It provides simple functionalities to do select, insert, update, delete, merge and join.
License
Sorm4j is distributed under a Apache License Version 2.0.
Repository
Private and experimental API
The classes in org.nkjmlab.sorm4j.internal are regarded as private API. Experimental elements are annotated by @Experimental.
Web page
To get started, see here.
Next to get started, see here.
The key features of Sorm4j, see here.
The detailed manual is here.
/yuunkjm/--.icon
Features
/yuunkjm/--.icon
Sorm4j is designed to be:
Simple
Sorm4j provides a simple way to access a JDBC database, usually in one line of code.
Sorm4j could be treated with simple POJO and Record class.
Performance: Sorm4j's overhead comparing to plain JDBC operations is low > Performance /yuunkjm/--.icon
Sorm4j supports :
Named parameters & ordered parameters
Sorm4j could handle named parameters and ordered parameters like that:
code:java
NamedParameterizedSqlParser.of("select * from players where id=:id").bind("id", 1);
Insert JavaObject directly
Sorm4j supports multi-row insert. Multi-row insert is faster than batch insert if you use H2 database.
code:java
sorm.insert(new Customer(1, "Alice", "Tokyo"));
sorm.insert(new Customer(2, "Bob", "Tokyo"), new Customer(3, "Carol", "Osaka"), new Customer(4, "Dave", "Nara"));
Simple transaction support
code:java
sorm.acceptHandler(Connection.TRANSACTION_READ_COMMITTED, conn -> {
conn.insert(Customer.ALICE);
// After the process of handler, the transaction is rollback automatically.
});
External connection pooling library: Sorm4j can be combined with other connection pooling library (e.g. HikariCP).
/yuunkjm/--.icon
Sorm4j is not:
not tested various RDBMS product
Sorm4j is only tested with H2. Most of functions of Sorm4j runnuble various RDBMS producs becase it uses standard SQL expressions . Som tests are executed by H2 compatibility Mode of MySQL, PostgreSQL, MS SQL Server and Oracle.
/yuunkjm/--.icon
Supported databases (Tested database)
Sorm4j is usable with the database which provids JDBC driver.
Tested databases (with high coverage test)
Tested databases (with test of basic object-relation mapping) @ v 1.3.19
MySQL (8.0.23) with JDBC driver 8.0.23 PostgreSQL (12.5-RC) with JDBC driver 42.2.19
Microsoft SQL Server (SQL Server Express Edition: SQL Server 2019 15.00.4073.23.v1) with JDBC driver 9.2.1.jre11
Oracle (19c SE2) with JDBC driver 19.10.0.0
/yuunkjm/--.icon
Other similar libraries