Symqle

Symqle is Java SQL query builder.

The starting point is database model, which contain a class for each table. The class contains methods to access columns and relations of the table. The model can be generated from database metadata with Symqle modeler.

I has many similarities with other Java query builders, e.g. JOOQ or jstorm and many differences.

Typical code may look like

Person person = new Person();
List<PersonData> personList = new PersonSelect(person)
    .where(person.title().eq("Developer").and(person.department().name().eq("R&amp;D"))
    .orderBy(person.id())
    .limit(10)
    .list(engine);

Comments: Person and Department classes represent database tables and are generated by Symqle modeler. PersonData is a data transfer object. You have to write it manually: usually your data transfer objects do not and must not mirror database structure. PersonSelect is a class, which defines mapping of database data to PersonDTO. It is easy to write the PersonSelect from scratch; Symqle provides powerful abstract classes to inherit from. Additionally, Symqle modeler generates samples of data transfer objects and mapping classes. You can copy them to your application and edit as needed.

There are no limitations on PersonData: it may have no public no-arg constructor, its members can be private and final - it is an arbitrary Java class. Symqle encourages object-oriented style of programming.

Symqle queries may be as simple as

List<String> people = person.lastName().list(engine);

or

person.update(person.salary.set(person.salary.mult(1.2))).execute(engine);

Symqle is easy to learn and use.

Read Symqle guide to meet exciting world of Symqle.

Features

  • Create virtually any SQL statement using pure Java API. Enjoy your IDE auto-completion features.
  • Compile-time check of queries against database model. Rebuild your model each time database schema changes and compile your code with new model jar. If there are incompatible changes, your code just would not compile.
  • Efficient resulting code with performance almost the same as direct use of JDBC API.
  • Code portability. Same code executes against all major RDBMS. Automatic choice of appropriate dialect.
  • Support of JDBC batching
  • Scroll operation, which allows to process result set rows one-by-one, preserving RAM.

Not supported

GROUP BY and HAVING are not supported and probably will never be supported. Symqle offers a number of workarounds.

Limitations of current version

This features are not implemented yet but are expected to be implemented in future releases.

Not implemented:

  • Insert from subquery
  • Replace statement
  • Sequences
  • Stored procedures

Limited support

This limitations apply to current versions. The features will be implemented in full later.

  • Set operations (UNION/EXCEPT/INTERSECT) are limited to single-column operands
  • Comparison and In predicates support only single-column predicands

If you have any questions of feel that there is a bug in Symqle, please visit Visit development site.