Skip to main content

Posts

Showing posts with the label persistence

Using jOOQ with Spring

Today a brief tutorial on how to integrate jOOQ ( http://www.jooq.org/ ) with Spring. It covers the basic integration that could be easily applied to any web application. For this tutorial I am referring to Spring 3.2.0 and jOOQ 2.6.1. I'm referring to Oracle because the applications I am working on use this database, but all the considerations done here are valid for each database vendor supported by jOOQ. Suppose you have a web application Spring based and want to integrate jOOQ with the most popular Inversion of Control container. First of all you have to put the jOOQ libraries in the WEB-INF/lib folder of  your application. The required jOOQ libraries are the following: jooq-2.6.1.jar jooq-codegen-2.6.1.jar jooq-meta-2.6.1.jar If you use the jOOQ code generation feature you need to add to the classpath also the jooq-codegen-2.6.1.jar library. Then you have to put in the WEB-INF/lib folder also the jOOQ dependencies: log4j-1.2.16.jar persistence-api-1...

jOOQ

jOOQ (Java Object Oriented Querying,  http://www.jooq.org/ ) is an Open Source library that provides a DSL to use SQL as it were natively supported by Java and treated in a object oriented way.  A SQL statement like this: SELECT * FROM BOOK WHERE PUBLISHED_IN = 2011 ORDER BY TITLE in jOOQ DSL becomes: create . selectFrom ( BOOK ) . where ( PUBLISHED_IN . equal ( 2011 )) . orderBy ( TITLE ) But jOOQ isn't just a DSL. It provides also other important features: Code Generation Active records Typesafe SQL SQL standard Vendor-specific feature support and supports the latest versions of the major database vendors.  jOOQ could be a powerful option to Hibernate or JPA. Tomorrow I am going to publish a post about the integration between Spring and jOOQ. Stay tuned!