Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jOOQ not generating DAOs with <daos> flag set to true

I have refreshed my project, cleanly rebuilt it, Googled/searched StackOverflow for similar problems, read the jOOQ documentation, examined the build output for potential issues, etc.

I added a <daos> flag to my pom.xml to generate jOOQ Database Access Objects, since the jOOQ 3.2.0 online manual says "DAO generation can be activated using the daos flag". According to the jOOQ Advanced Codegen documentation setting this flag to true generates not only DAO's, but also relations, records, and POJOs:

<generator>
    ...
    <generate>
        <daos>true</daos>
    </generate>   
</generator>

Prior to adding the flag to my pom, I had auto-generated records and relations but neither POJOs nor DAOs. After adding the daos flag and rebuilding my project, I also have POJOs plus the other two but I still don't have any DAOs. The attached screenshot shows my generated classes. The classes added by the flag are in the blue box. I think there should be a package named something like "daos" with PurchaseDAO and UserDAO classes.

The jOOQ DAO documentation doesn't explain any cases where the flag is added but DAOs aren't generated. Part of the point of this project is to learn jOOQ so manually coding DAOs with jOOQ classes won't solve my problem.

EDIT: My SQLite 3.7.11 schema from the working and non-working solutions are here.

like image 811
JaneGoodall Avatar asked Jan 16 '14 20:01

JaneGoodall


2 Answers

I've found in your console output that DAO is skipping,

INFO: Generating DAOs Jan 16, 2014 12:40:45 PM org.jooq.tools.JooqLogger info INFO: Skipping DAO generation : PurchaseDao.java Jan 16, 2014 12:40:45 PM org.jooq.tools.JooqLogger info INFO: Skipping DAO generation : UserDao.java Jan 16, 2014 12:40:45 PM org.jooq.tools.JooqLogger info INFO: Table DAOs generated : Total: 212.968ms, +1.759ms

After that cheked code and found next

// [#2573] Skip DAOs for tables that don't have 1-column-PKs (for now)
1287        if (keyColumn == null) {
1288            log.info("Skipping DAO generation", getStrategy().getFileName(table, Mode.DAO));
1289            return;
1290        }
like image 97
Sergii Zagriichuk Avatar answered Nov 15 '22 04:11

Sergii Zagriichuk


I was facing the same problem today (2017).

In your configuration file, the same used on line command, e.g:

java -classpath jooq-3.10.2.jar:jooq-meta-3.10.2.jar:jooq-codegen-3.10.2.jar:mysql-connector-java-5.1.45-bin.jar:. org.jooq.util.GenerationTool 

In configuration.xml, put between the tags "generator" the tag "generate" with parameters respectively.

E.g:

<generator>
    ...
    <generate> 
        <pojos>false</pojos>
        <daos>true</daos>
         ...
    </generate>   
</generator> 

See more about these the parameters here.

like image 1
Jésus T. Lacerda Avatar answered Nov 15 '22 03:11

Jésus T. Lacerda