GithubHelp home page GithubHelp logo

isabella232 / lsql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from w11k/lsql

0.0 0.0 0.0 1.98 MB

Java SQL Database Library

Home Page: https://github.com/w11k/lsql/blob/master/README.md

License: Apache License 2.0

Shell 0.90% Java 99.10%

lsql's Introduction

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.

Example

CRUD

Given the following DDL:

CREATE TABLE person (
    id SERIAL PRIMARY KEY,
    name VARCHAR(200),
    age INT
);

Java code:

// insert
Person_Table personTable = new Person_Table(lSql);
Person_Row person = new Person_Row()
    .withName("John")
    .withAge(20);
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;

Query

Given the following SQL statement file PersonStatements.sql:

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

Java code:

PersonStatements statements = new PersonStatements(lSql);

List<LoadPersonByAge> list = personStatements.loadPersonByAge()
    .withAge(20)
    .toList();

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

Download

Maven Repository Artifacts

All released files are stored in a Maven repository:

<repositories>
    <repository>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
        <id>bintray-w11k-lsql</id>
        <name>bintray</name>
        <url>https://dl.bintray.com/w11k/lsql</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.w11k.lsql</groupId>
        <artifactId>lsql-core</artifactId>
        <version>...</version>
    </dependency>
    <dependency>
        <groupId>com.w11k.lsql</groupId>
        <artifactId>lsql-guice</artifactId>
        <version>...</version>
    </dependency>
    <dependency>
        <groupId>com.w11k.lsql</groupId>
        <artifactId>lsql-cli</artifactId>
        <version>...</version>
    </dependency>
</dependencies>

lsql's People

Contributors

romanroe avatar gitter-badger 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.