This sample project shows how you can use jOOQ in your Ceylon project. It illustrates a blog article I wrote.
To compile and run the sample project, you'll need:
- Ceylon 1.3.2 and Java 8, and
- MySQL database.
To develop the sample project in an IDE, install Ceylon IDE for IntelliJ or Eclipse.
jOOQ's code generator was used to create a Java model
representing all the tables. The model was generated into
the Ceylon module gen.example.jooq in the gen-source
directory.
The blog article shows a sample configuration
that can be used to regenerate the model. Don't forget to
add jooq-3.9.1.jar, jooq-meta-3.9.1.jar,
jooq-codegen-3.9.1.jar, and a MySQL JDBC driver to the
classpath when invoking org.jooq.util.GenerationTool.
The actual example module example.jooq is located in the
directory source/. It uses jOOQ's generated classes to
query the sakila database, then prints the results.
The sample project uses the standard example MySQL database
named sakila. You can create it using these SQL files,
by following these instructions.
Compile the code by typing:
ceylon compile
Next, make sure that the MySQL server is running, and run the example with:
ceylon run example.jooq
To assemble a "fat" jar archive containing the example module and its dependencies, type:
ceylon fat-jar example.jooq
Then run it using:
java -jar example.jooq-1.0.0.jar
To create a Ceylon assembly with the example module and its dependencies, type:
ceylon assemble example.jooq
Then run it using:
ceylon run --flat-classpath --assembly=example.jooq-1.0.0.cas