11

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.

11
  • Just checked JOOQ version 3.2, all is good, DAOs are generated, BTW, generated DAOs are simple implementation of the org.jooq.impl.DAOImpl, most DAO methods are present in that class, in generated just a few find/fetch additional methods. Jan 16, 2014 at 21:00
  • No @SergiiZagriichuk, they aren't being generated in my project despite the daos flag. I wouldn't ask the question if DAOs were being generated. Jan 16, 2014 at 21:04
  • maybe you also need the <pojos>true</pojos>?
    – assylias
    Jan 16, 2014 at 21:04
  • @assylias no daos - > enables pojos Jan 16, 2014 at 21:05
  • @JaneGoodall have you tried from console or just from Eclipse ? Jan 16, 2014 at 21:06

3 Answers 3

14

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        }
4
  • Wow thanks, that looks like the solution. I'll regenerate the table to use non-row_id primary keys. If it works I'll upvote this and mark it as Accepted. Jan 16, 2014 at 21:35
  • If anyone else is reading this, you may have to refresh your project to see the DAOs. Just right-click the project in Eclipse and select Refresh. Jan 16, 2014 at 23:08
  • @JaneGoodall: Very interesting! Would you mind adding a DDL of the table with "row_id primary keys" to your question for future visitors to understand what might be going wrong? I guess this is quite SQLite-specific
    – Lukas Eder
    Jan 17, 2014 at 7:31
  • The db user that i was using didn't have permission to return primary key information. So i tried with an user that has elevated permission and the DAO got created. The DB is Postgres and probably the user is missing permission on information_schema or some other table where these information needed to generate resides.
    – iamprem
    Feb 7, 2020 at 23:17
1

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.

0

The configuration includePrimaryKeys must be settled.

<includePrimaryKeys>true</includePrimaryKeys>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.