Java SQL Database Library
Switch branches/tags
Clone or download

Build Status

Literate SQL - A Java Database Library

LSql (Literate SQL) is a Java database library focusing on type-safety and the preservation of the relational data model.

Key points:

  • LSql is not yet another object/relational mapper. We believe that functional application data (in particular stored in a relational model) should not be mapped to a strict classes/objects model. The relational data model is elegant, well-thought-out and a reliable way to model the application data. Any abstraction between the relational model and the application logic makes things more complicated and should be avoided.

  • Based on your database schema and SQL statement files, LSql generates Java classes (with an immutability API design) in order to interact with the database in a type-safe manner.

  • SQL is a superior language for data manipulation. The RDBMS should be choosen depending on the project requirements and database access libraries should not try to hide their characteristics.



Given the following DDL:

    name VARCHAR(200),
    age INT

Java code:

// insert
Person_Table personTable = new Person_Table(lSql);
Person_Row person = new Person_Row()
Optional<Integer> pk = personTable.insert(person);

// load by ID
Optional<Person_Row> personRowOptional = personTable.load(pk.get());
personRowOptional.get().name == "John";
personRowOptional.get().age == 20;


Given the following SQL statement file PersonStatements.sql:

SELECT * FROM person WHERE age = /*=*/ 0 /**/;

Java code:

PersonStatements statements = new PersonStatements(lSql);

List<LoadPersonByAge> list = personStatements.loadPersonByAge()

list.get(0).name == "John";
list.get(0).age == 20;


Maven Repository Artifacts

All released files are stored in a Maven repository: