Git Product home page Git Product logo

uroborosql's Introduction

Maven Central GitHub license Javadocs Build Status Coverage Status

uroboroSQL

uroboroSQL

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.

asciicast

for Japanese, see README.ja.md

Installation

for Maven

<dependency>
    <groupId>jp.co.future</groupId>
    <artifactId>uroborosql</artifactId>
    <version>0.24.0</version>
</dependency>
<dependency>
    <groupId>ognl</groupId>
    <artifactId>ognl</artifactId>
    <version>3.1.23</version>
</dependency>

or

<dependency>
    <groupId>jp.co.future</groupId>
    <artifactId>uroborosql</artifactId>
    <version>0.24.0</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>5.2.2.RELEASE</version>
</dependency>

for Gradle

compile group: 'jp.co.future', name: 'uroborosql', version: '0.24.0'
compile group: 'ognl', name: 'ognl', version: '3.1.23'

or

compile group: 'jp.co.future', name: 'uroborosql', version: '0.24.0'
compile group: 'org.springframework', name: 'spring-expression', version: '5.2.2.RELEASE'

Documentation

https://future-architect.github.io/uroborosql-doc/

Requirement

  • Java 1.8 or later.

Quick start

2Way-SQL

/* 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();
}

DAO Interface

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);
}

Sample application

Automated code generation

SQL Formatter

uroboroSQL

We also prepare a SQL formatter useful for development.

License

Released under the MIT License.

uroborosql's People

Contributors

futa23 avatar future-oss avatar hidekisugimoto189 avatar ota-meshi avatar shout-star avatar ymaegawa avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.