Firebird Documentation IndexFirebird 3.0 Developer's GuideCreating an Application with jOOQ and Spring MVC → Generating classes for jOOQ
Firebird Home Firebird Home Prev: Start-up Code—WebInitializerFirebird Documentation IndexUp: Creating an Application with jOOQ and Spring MVCNext: Dependency Injection

Generating classes for jOOQ

Table of Contents

jOOQ Classes

Work with the database will be carried out using the jOOQ library. jOOQ builds SQL queries from jOOQ objects and code (similarly to LINQ). jOOQ is more closely integrated with the database than ORM, enabling more database features to be utilized, rather than just the simple CRUD SQL queries used in Active Record. jOOQ can work with stored procedures and functions, sequences, and use window functions and other Firebird-specific features.

You can find the full documentation for jOOQ at http://www.jooq.org/doc/3.9/manual-single-page/.

jOOQ Classes

jOOQ classes for working with the database are generated on the basis of the database schema described in the earlier chapter, The examples.fdb Database.

To generate jOOQ classes for working with our database, you will need to download these binary files at http://www.jooq.org/download or via the maven repository:

  • jooq-3.9.2.jarThe main library included in our application for working with jOOQ
  • jooq-meta-3.9.2.jar—The tool included in your build for navigating the database schema via generated objects
  • jooq-codegen-3.9.2.jar—The tool included in your build for generating the database schema

Along with those, of course, you will need to download the Jaybird driver for connecting to the Firebird database via JDBC: jaybird-full-3.0.0.jar.

Configuration for Database Schema Classes

For generating the classes for the database schema, we create the configuration file example.xml:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.8.0.xsd">
  <!-- Configuration of connection to the database -->
  <jdbc>
    <driver>org.firebirdsql.jdbc.FBDriver</driver>
    <url>jdbc:firebirdsql://localhost:3050/examples</url>
    <user>SYSDBA</user>
    <password>masterkey</password>
    <properties>
      <property>
        <key>charSet</key>
        <value>utf-8</value>
      </property>
    </properties>
  </jdbc>

  <generator>
    <name>org.jooq.util.JavaGenerator</name>

    <database>
      <!-- The type of the database. Format:
           org.util.[database].[database]Database -->
      <name>org.jooq.util.firebird.FirebirdDatabase</name>

      <inputSchema></inputSchema>

      <!-- All objects that are generated from your schema 
           (Java regular expression. Use filters to limit number of objects).  
           Watch for sensitivity to the register. Depending on your database, 
           this can be important! 
       -->
      <includes>.*</includes>

      <!-- Objects that are excluded when generating from your schema.
           (Java regular expression).
           In this case, we exclude system tables RDB$, monitoring tables MON$ 
           and security pseudo-tables SEC$. 
      -->
      <excludes>
          RDB\$.*
        | MON\$.*
        | SEC\$.*
      </excludes>
    </database>

    <target>
      <!-- The name of the package to which the generated -->
      <packageName>ru.ibase.fbjavaex.exampledb</packageName>

      <!-- Directory for posting the generated classes.
           Here, the Maven directory structure is used. -->
      <directory>e:/OpenServer/domains/localhost/fbjavaex/src/main/java/</directory>
    </target>
  </generator>
</configuration>
          

Generating the Schema Classes

In the the command shell, execute the following command to create the classes needed for writing queries to database objects in Java:

java -cp jooq-3.9.2.jar;jooq-meta-3.9.2.jar;jooq-codegen-3.9.2.jar;
jaybird-full-3.0.0.jar;. org.jooq.util.GenerationTool example.xml
          

You can find more details about the process of generating classes at https://www.jooq.org/doc/3.9/manual-single-page/#code-generation.

Prev: Start-up Code—WebInitializerFirebird Documentation IndexUp: Creating an Application with jOOQ and Spring MVCNext: Dependency Injection
Firebird Documentation IndexFirebird 3.0 Developer's GuideCreating an Application with jOOQ and Spring MVC → Generating classes for jOOQ