Statements Attributes and Elements

SQLegance there is not coupled with JDBC technology, that means it can be used with any framework that you like.

But it was thought beyond that, there are some characteristics to supports a full JDBC implementation and some enhanced.

timeout

Define a number of seconds the driver will wait for a statement to be executed.

<select timeout="3500">

isolation

The transaction isolation level.

<select isolation="READ_COMMITTED">

Isolation levels:

  • READ_COMMITTED
  • READ_UNCOMMITTED
  • REPEATABLE_READ
  • SERIALIZABLE

Shortnames

When enabled you can refer the a query separated by dot with last name: getUsers

<select id="com.acme.sample.getUsers">

To enable the property jkniv.repository.short_name_enable must be true into repository-config.xml file.

<repository ...>
  ...
  <properties>
    <property name="jkniv.repository.short_name_enable" value="true"/>
  </properties>
</repository>

Validation

To support Bean Validation.

<select id="users-by-name" validation="LIST">
  SELECT id, name FROM users WHERE name LIKE :name
</select>

<delete id="remove-user-by-id" validate="REMOVE">
 DELETE FROM users WHERE id = :id 
</delete>

Validation groups:

  • NONE
  • ALL
  • GET
  • LIST
  • SELECT
  • ADD
  • UPDATE
  • REMOVE
  • ENRICH
  • SCALAR

Auto Generated Key

To instrument the JDBC to return the generated keys. Depends from you fully implementation.

<autoGeneratedKey strategy="AUTO" properties="id"/>

Strategies types:

  • AUTO
  • SEQUENCE

One-to-Many

Defines a association with one-to-many multiplicity, allowing the tabular result from SELECT whether transform into Object relationship one-to-many.

<select groupBy="id">
  <one-to-many property="books" typeOf="org.acme.model.Book"/>
  ...
</select>

Cache

To enable a level of result cache.

<statements 
  xmlns="http://jkniv.sf.net/schema/sqlegance/statements" 
  xmlns:cache="http://jkniv.sf.net/schema/sqlegance/cache"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xmlns:xi="http://www.w3.org/2001/XInclude"
  xsi:schemaLocation="http://jkniv.sf.net/schema/sqlegance/statements
   http://jkniv.sf.net/schema/sqlegance/sqlegance-stmt.xsd
   http://jkniv.sf.net/schema/sqlegance/cache
   http://jkniv.sf.net/schema/sqlegance/sqlegance-cache.xsd">

  <cache:cache-manager delay="120" period="600"  ttl="300" tti="120" size="10000" sizeof="5M">
    <cache:policy name="user-cache" ttl="900" tti="300" size="15000" sizeof="2M"/>
  </cache:cache-manager>

<select id="user-by-id" cache="user-cache">
 SELECT id, name FROM users WHERE id = :id
</select>

A full implementation of this characteristics was implemented on top of jkniv-whinstone framework that will help you eliminate the boilerplate code. jkniv-whinstone is tight coupled with JDBC and you will not remember it. One repository contract to get a java code agnostic for database and API like: JPA, JDBC, Apache CouchDB, Apache Cassandra. Run, Forrest, run…