UroboroSQL is a simple SQL execution library that can utilize 2-way-SQL compatible with Java 8.
UroboroSQL mainly adopts a SQL-centered design concept. The concept does not focus on Java to assemble SQL, but is based on an idea of making up for weaknesses of SQL with Java.
From the knowhow acquired through our business, we have enhanced UroboroSQL with functions like partition value support, retrying, filtering customization, and so on. Also, for quality assurance purposes, it features a coverage analysis function available for 2-way-SQL.
There is also REPL which dramatically increases SQL development productivity.
for Japanese, see README.ja.md
<dependency>
<groupId>jp.co.future</groupId>
<artifactId>uroborosql</artifactId>
<version>0.15.2</version>
</dependency>
compile group: 'jp.co.future', name: 'uroborosql', version: '0.15.2'
https://future-architect.github.io/uroborosql-doc/
- Java 1.8 or later.
/* department/select_department.sql */
SELECT /* _SQL_ID_ */
DEPT.DEPT_NO AS DEPT_NO
, DEPT.DEPT_NAME AS DEPT_NAME
FROM
DEPARTMENT DEPT
WHERE
1 = 1
/*IF SF.isNotEmpty(dept_no)*/
AND DEPT.DEPT_NO = /*dept_no*/1
/*END*/
/*IF SF.isNotEmpty(dept_name)*/
AND DEPT.DEPT_NAME = /*dept_name*/'sample'
/*END*/
/* department/insert_department.sql */
INSERT
/* _SQL_ID_ */
INTO
DEPARTMENT
(
DEPT_NO
, DEPT_NAME
) VALUES (
/*dept_no*/1
, /*dept_name*/'sample'
)
SqlConfig config = UroboroSQL.builder("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "").build();
try (SqlAgent agent = config.agent()) {
// SELECT
List<Map<String, Object>> departments = agent.query("department/select_department").param("dept_no", 1001).collect();
// INSERT
int count = agent.update("department/insert_department")
.param("dept_no", 1001)
.param("dept_name", "sales")
.count();
}
SqlConfig config = UroboroSQL.builder("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1", "sa", "").build();
try (SqlAgent agent = config.agent()) {
// select
Department dept =
agent.find(Department.class, 1001).orElse(null);
// insert
Department hrDept = new Department();
hrDept.setDeptNo(1002);
hrDept.setDeptName("HR");
agent.insert(hrDept);
// update
hrDept.setDeptName("Human Resources");
agent.update(hrDept);
// delete
agent.delete(hrDept);
}
- CLI
- Web application(with Spring Boot)
- uroboroSQL source generator
We also prepare a SQL formatter useful for development.
- CLI
- Sublime Text 3 Plugin
- IntelliJ IDEA Platform Plugin
- Eclipse Plugin
Released under the MIT License.