Huh, what does the generated code of your schema look like?

2015-06-02 16:50 GMT+02:00 Robert DiFalco <robert.difa...@gmail.com>:

> Hmmm...I added that property to the database section and every time I run
> "mvn test" I get this output (and it regenerates).
>
> [INFO] Generating schemata      : Total: 1
> [INFO] No previous version available for schema public. Regenerating.
> [INFO] Generating schema        : Public.java
>
> I'm using flyway and my pom.xml looks like this:
>
> <plugin>
>     <!-- Specify the maven code generator plugin -->
>     <groupId>org.jooq</groupId>
>     <artifactId>jooq-codegen-maven</artifactId>
>     <version>3.6.1</version>
>
>     <!-- The plugin should hook into the generate goal -->
>     <executions>
>         <execution>
>             <phase>generate-sources</phase>
>             <goals>
>                 <goal>generate</goal>
>             </goals>
>         </execution>
>     </executions>
>
>     <!-- Specify the plugin configuration.
>          The configuration format is the same as for the standalone code 
> generator -->
>     <configuration>
>         <!-- JDBC connection parameters -->
>         <jdbc>
>             <driver>org.postgresql.Driver</driver>
>             <url>${database.jdbcUrl}</url>
>             <user>${database.username}</user>
>             <password>${database.password}</password>
>         </jdbc>
>
>         <!-- Generator parameters -->
>         <generator>
>             <name>org.jooq.util.JavaGenerator</name>
>             <database>
>                 <name>org.jooq.util.postgres.PostgresDatabase</name>
>                 <includes>.*</includes>
>                 <inputSchema>public</inputSchema>
>                 <!--<outputSchemaToDefault>true</outputSchemaToDefault>-->
>                 <schemaVersionProvider>SELECT :schema_name || '_' || 
> MAX("version") FROM "schema_version"</schemaVersionProvider>                  
>       </database>
>             <target>
>                 <packageName>com.waiapp.server.jooq</packageName>
>                 <directory>src/main/java</directory>
>             </target>
>             <generate>
>                 <deprecated>false</deprecated>
>             </generate>
>         </generator>
>     </configuration>
> </plugin>
>
>
> On Tue, Jun 2, 2015 at 7:35 AM, Lukas Eder <lukas.e...@gmail.com> wrote:
>
>> Hmm, interesting. I would have thought this is documented in the manual,
>> but it appears it isn't. You can use <schemaVersionProvider/> for this:
>>
>> <!--
>>  A custom version number that, if available, will be used to assess
>> whether the above
>> <inputSchema/> will need to be regenerated.
>>  There are three operation modes for this element:
>>  - The value is a class that can be found on the classpath and that
>> implements
>> org.jooq.util.SchemaVersionProvider. Such classes must provide a default
>> constructor
>> - The value is a SELECT statement that returns one record with one
>> column. The
>> SELECT statement may contain a named variable called :schema_name
>> - The value is a constant, such as a Maven property
>>  Schema versions will be generated into the javax.annotation.Generated
>> annotation on
>> generated artefacts.
>> -->
>> <element name="schemaVersionProvider" type="string" default="" minOccurs
>> ="0" maxOccurs="1"/>
>>
>>
>> (from http://www.jooq.org/xsd/jooq-codegen-3.6.0.xsd)
>>
>> The code generator won't regenerate the schema if it has the same version
>> as provided by the SchemaVersionProvider... One use-case is precisely to
>> specify a query that reads Flyway's version table. For more info, see this
>> feature request here:
>> https://github.com/jOOQ/jOOQ/issues/3121
>>
>> E.g.
>>
>>  <schemaVersionProvider>SELECT :schema_name || '_' || MAX("version") FROM 
>> "schema_version"</schemaVersionProvider>
>>
>>
>> I've added an issue to document this in the manual:
>> https://github.com/jOOQ/jOOQ/issues/4348
>>
>> Cheers,
>> Lukas
>>
>> 2015-06-02 16:22 GMT+02:00 Robert DiFalco <robert.difa...@gmail.com>:
>>
>>> Interesting, I'll look into those classes to see what they do.
>>>
>>> One thing that occurs to me is that it would be nice to be able to
>>> customize the code that decides if java files need to be changed/created.
>>> For example, I use Flyway so I have a hash of my latest schema changes. It
>>> would be nice to be able to do a quick lookup on the last hash Jooq
>>> generated for (and the Jooq version) to see if anything needs to be done.
>>> I'm fine with regenerating if generator configuration options change. That
>>> could make things very fast. Yes, it is a local database.
>>>
>>> On Monday, June 1, 2015 at 11:16:15 PM UTC-7, Lukas Eder wrote:
>>>>
>>>> I don't think that the code generation itself is the bottleneck.
>>>> Between subsequent generations, only deltas are re-generated (class
>>>> additions / removals / changes) to allow for incremental compilation of
>>>> generated code.
>>>>
>>>> Probably, the queries against the dictionary views / information_schema
>>>> might not be optimal. Did you measure things at your side? Is there
>>>> anything particular that you found to be slow? Are you generating code
>>>> against a local database on your computer, or a remote one - possibly cloud
>>>> hosted one?
>>>>
>>>> One way to speed up code generation would be to use jOOQ's XMLDatabase,
>>>> or implement your own org.jooq.util.Database from jOOQ meta, that is
>>>> optimised for your specific schema. Let me know if that sounds like an
>>>> option to you, and I'll explain more
>>>>
>>>> 2015-06-01 22:38 GMT+02:00 Robert DiFalco <robert....@gmail.com>:
>>>>
>>>>> While I have you, is there any simple way to speed up the code
>>>>> generation phase in the maven plugin? mvn test can take a while doing the
>>>>> generation each time. I only have one schema, does adding:
>>>>>
>>>>> <outputSchemaToDefault>true</outputSchemaToDefault>
>>>>>
>>>>> Save me any time? Anything else I can look at? I'm not generating
>>>>> beans or anything like that.
>>>>>
>>>>
>>>> No, that shouldn't have any impact on the code generation speed. It is
>>>> just used to omit the schema in generated output, which is useful in
>>>> single-schema / multi-tenant environements.
>>>>
>>>  --
>>> 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 jooq-user+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "jOOQ User Group" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/jooq-user/7jqbm98_Ga8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> jooq-user+unsubscr...@googlegroups.com.
>> 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 jooq-user+unsubscr...@googlegroups.com.
> 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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to