Skip to main content

Posts

Showing posts with the label DSL

Apache Camel rocks!

Yesterday I attended a meeting of the JBoss User Group @ Red Hat in Rome. One of the two topics of this meeting was an introduction to Apache Camel ( http://camel.apache.org/ ). Last summer Red Hat acquired Fuse Source and now they are promoting Apache Camel. It is a powerful Open Source integration framework based on the most used Enterprise Integration Patterns (EIPs,  http://www.eaipatterns.com/toc.html ).  Camel allows you to define routing and mediation rules in a lot of domain-specific languages, including Java, Spring, XML and Scala DSL. It provides more than 120 components and so it's possible to work directly with any kind of  transport or messaging model. The following image taken from the official website shows the Camel architecture: Camel brings a lot of benefits. How many times it would have been useful in some past projects! But it's never too late to start with it.

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!