Hi Dominik,

Thank you very much for your enquiry. The use of the JPADatabase is
documented here (only maven syntax, but gradle should be equivalent):
http://www.jooq.org/doc/latest/manual/code-generation/codegen-jpa

<generator>
    <database>
        <name>org.jooq.util.jpa.JPADatabase</name>
        <properties>
            <!-- A comma separated list of Java packages, that contain
your entities -->
            <property>
                <key>packages</key>
                <value>com.example.entities</value>
            </property>
        </properties>
    </database></generator>


If a "database" requires additional arguments like in this case the
packages containing entities, this is done through a generic properties
"hashmap". In your case, you would probably need to write:

jooq {
    sample(sourceSets.main) {
        generator {
            name = 'org.jooq.util.DefaultGenerator'
            strategy {
                name = 'org.jooq.util.DefaultGeneratorStrategy'
            }
            database {
                name = 'org.jooq.util.jpa.JPADatabase'
                properties {
                    property {
                        key = 'packages'
                        value = 'com.example.jpa'
                    }
                }
            }
            generate {
            }
            target {
                packageName = 'com.example.db'
                directory = 'src/main/java'
            }
        }
    }
}

Please, let me know if this helps.
Best Regards,
Lukas

2016-10-19 18:39 GMT+02:00 Dominik Gruntz <[email protected]>:

> I try to generate code from JPA entities using the "database"
> org.jooq.util.jpa.JPADatabase, but I am working with the JOOQ-Gradle-Plugin
> provided by Etienne Studer (https://github.com/etiennestuder/gradle-jooq-
> plugin).
>
>
> The question is how the list of packages containing the JPA entities can
> be specified. I have tried the following specification:
>
> jooq {
>     sample(sourceSets.main) {
>         generator {
>             name = 'org.jooq.util.DefaultGenerator'
>             strategy {
>                 name = 'org.jooq.util.DefaultGeneratorStrategy'
>             }
>             database {
>                 name = 'org.jooq.util.jpa.JPADatabase'
>                 packages = 'com.example.jpa'
>             }
>             generate {
>             }
>             target {
>                 packageName = 'com.example.db'
>                 directory = 'src/main/java'
>             }
>         }
>     }
> }
>
>  If I use the following definition, then Gradle prints the following error
> message:
>
> * What went wrong:
> A problem occurred evaluating root project 'spring-gs-jooq'.
> > Invalid property: 'packages' on extension 'jooq.sample.generator.database',
> value: com.example.jpa
>
> and if I drop the package property altogether then I get (as expected) the
> warning
>
> No packages defined      : It is highly recommended that you provide
> explicit packages to scan
>
> followed by the exception
>
> org.jooq.exception.DataAccessException: Error while exporting schema
>         at org.jooq.util.jpa.JPADatabase.create0(JPADatabase.java:111)
>         at org.jooq.util.AbstractDatabase.create(
> AbstractDatabase.java:209)
>         at org.jooq.util.AbstractDatabase.create(
> AbstractDatabase.java:201)
>         at org.jooq.util.AbstractDatabase.getDialect(
> AbstractDatabase.java:183)
>         at org.jooq.util.JavaGenerator.generate(JavaGenerator.java:209)
>         at org.jooq.util.GenerationTool.run(GenerationTool.java:426)
>         at org.jooq.util.GenerationTool$run.call(Unknown Source)
>
>
> Any help is appreciated.
> Thanks!
> Dominik
>
> --
> You received this message because you are subscribed to the Google Groups
> "jOOQ User Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to