jOOQ allows code generation from a database schema through ANT tasks, Maven and shell command tools. But if you're working with Eclipse it's easier to create a new Run Configuration to perform this operation.
First of all you have to write the usual XML configuration file for the code generation starting from the database:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
<jdbc>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>
<user>DB_FTRS</user>
<password>password</password>
</jdbc>
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<database>
<name>org.jooq.util.oracle.OracleDatabase</name>
<inputSchema>DB_FTRS</inputSchema>
<includes>.*</includes>
<excludes></excludes>
</database>
<generate>
<relations>true</relations>
<deprecated>false</deprecated>
<pojos>true</pojos>
<daos>true</daos>
</generate>
<target>
<packageName>jooqbench.generated</packageName>
<directory>src</directory>
</target>
</generator>
</configuration>
Then you have to be sure to have in your project classpath the following libraries:
Move to the Arguments tab and add as Program argument your jOOQ configuration file for code generation putting a slash before its name:
Click on the Run button and the generation will start. Each time you need to refresh your code, just run this configuration.
First of all you have to write the usual XML configuration file for the code generation starting from the database:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">
<jdbc>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>
<user>DB_FTRS</user>
<password>password</password>
</jdbc>
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<database>
<name>org.jooq.util.oracle.OracleDatabase</name>
<inputSchema>DB_FTRS</inputSchema>
<includes>.*</includes>
<excludes></excludes>
</database>
<generate>
<relations>true</relations>
<deprecated>false</deprecated>
<pojos>true</pojos>
<daos>true</daos>
</generate>
<target>
<packageName>jooqbench.generated</packageName>
<directory>src</directory>
</target>
</generator>
</configuration>
Then you have to be sure to have in your project classpath the following libraries:
- jooq-2.6.1.jar
- jooq-codegen-2.6.1.jar
- jooq-meta-2.6.1.jar
- log4j-1.2.16.jar
- slf4j-log4j12-1.7.2.jar
Move to the Arguments tab and add as Program argument your jOOQ configuration file for code generation putting a slash before its name:
Click on the Run button and the generation will start. Each time you need to refresh your code, just run this configuration.
Comments
Post a Comment