Introduction :
Step 1:
Add the Generator plugin in Maven pom.xml.
3.3.1 org.jooq jooq ${jooq-version} org.jooq jooq-meta ${jooq-version} org.jooq jooq-codegen ${jooq-version} org.jooq jooq-codegen-maven ${jooq-version} generate mysql mysql-connector-java 5.1.30 com.mysql.jdbc.Driver jdbc:mysql://localhost/jooq_test root root org.jooq.util.DefaultGenerator org.jooq.util.mysql.MySQLDatabase .* jooq_test com.the13star.entities src/main/java
For JOOQ we need some dependencies to add in the pom.xml file. But the generator plugin also need some dependencies for plugin use only. That dependencies are declare in the generator plugin. If we already declare dependencies in dependency block and not declare in plugin the generator will not run. We again need to declare dependencies in the generator plugin, because plugin use its individual dependencies for run like MySQL dependency in the above code. If maven provide the way to use dependencies of dependency block in plugin please discuss.
In this we use DefaultGenerator for generate Entities, you can also use your custom generator.
Step 2
For run the generator use Maven install command from eclipse or command line, after generator run, there are three packages structures are automatically create in your project.
The three pakcages are
1. com.the13star.dbmetadata: According to its name it is used to represent meta information of database table. Like Kyes.java contain information regarding primary key's etc.
2. com.the13star.dbmetadata.tables: This package contain the information of db tables like. Field in table, types of column etc. One java file represent one table. according to above example there is only one table in DB.
3. com.the13star.dbmetadata.tables.records: This package represent the record of table or represent the one row in table. We will also said that, this is our Java POJO or Entity file.
No comments:
Post a Comment