Skip to content

Latest commit

 

History

History
39 lines (31 loc) · 2.4 KB

README.md

File metadata and controls

39 lines (31 loc) · 2.4 KB

Core module of Stalactite

This module aims at providing a simple mapping between Beans and RDBMS tables. It doens't target relations management between them, except for querying.

Main entry point of this module is ClassMappingStrategy for persisting entities. But you may also persist strange things like :

You can query your database creating Querys. Combined with QueryBuilder you can get executable SQL. Here's a simple example with a QueryEase static import:

QueryProvider q = select(personTable.firstName, personTable.birthDate).from(personTable);
System.out.println(new QueryBuilder(q).toSQL())
// will print : select firstName, birthDate from Person; 

A 2-tables-join one:

Table personTable = new Table("Person");
Column personId = personTable.addColumn("id", Long.class);
Column firstname = personTable.addColumn("firstname", String.class);
Column lastname = personTable.addColumn("lastname", String.class);
Table carTable = new Table("Car");
Column ownerId = carTable.addColumn("owner", Long.class);
Column carColor = carTable.addColumn("color", String.class);

QueryProvider q = select(firstname, lastname, carColor).from(personTable, "p").innerJoin(personId, ownerId).where(lastname, like("%jo%"));
System.out.println(new QueryBuilder(q).toSQL())
// will print : select p.firstname, p.lastname, c.color from Person as p inner join Car as c on p.id = c.owner where p.lastname like '%jo%'

Please refer to this test for examples.

Caveat

Thus, by using this module you must have skills in schema design : you won't be helped in designing relations between tables to handle entity inheritance or entity relations : for all of this you should be interested in ORM module.