We have been using some the jOOQ generator for a while to generate some sources for use as the underlying "implementation" of data entities for interacting with a database:
base/target/generated-sources/jooq/com.example.db1.generated/{enums,routines}/*.java
base/target/generated-sources/jooq/com.example.db1.generated/{tables/udt}/{interfaces,pojos,records}/*.java
base/target/generated-sources/jooq/com.example.db2.generated/{enums,routines}/*.java
base/target/generated-sources/jooq/com.example.db2.generated/{tables/udt}/{interfaces,pojos,records}/*.java
And then in the actual source of our project:
base/src/main/java/com.example.db1.entities/*.java
base/src/main/java/com.example.db2.entities//*.java
The entities usually inherit from a table interface generated by jOOQ and take advantage of that to allow us to use jOOQ to execute type safe statements.
Our problem is with the generation and maintenance of these jOOQ classes. Ideally, we'd like to avoid requiring each developer to have to connect to these databases during build if they aren't touching the schema itself.
We have been trying to use the XMLDatabase generator to let a developer pull down the project, and run a compile which would use the jOOQ generator to generate the source files from a committed copy of the schema in an XMLDatabase. If the developer were making changes to the schema, then they would run a maven profile to generate a new XMLDatabase schema and commit that change.
There continue to be a few pieces missing in that solution that prevents it from fully working:
* Postgres enums don't seem to be generated into the XMLDatabase ( no issue yet, didn't see anything similar in searches )
* UDTs seem to lose type information when generated from an XMLDatabase instead of directly from a Postgres DB ( needs further investigation on our end )
So, for now, we are doing something much less enjoyable which is for a developer with the ability to connect to both databases to run the generator and actually commit the generated sources in the target/generated-sources directory.
This isn't great because normally the target folder is excluded in .gitignore.
So now, my list of questions for ideas and "best practices":
* Do people normally generate source files to target/generated-sources or to their actual source tree?
* Do they commit the resulting generated source files in VCS?
* Are all developers typically expected to generate new sources on each build, even if they are potentially working with large databases that can be very slow to generate over a remote connection?
* Is the XMLDatabase mechanism intended to be used as a solution to this type of scenario or are we "abusing" it?
I welcome your feedback, thank you!
-Daniel