I'm currently evaluating JOOQ
because I believe I started reinventing the wheel which looks very close to part of JOOQ
:)
Now, while digging in great JOOQ
documentation I've found that my use case lies somewhere between Using JOOQ as SQL Builder and Using JOOQ as SQL Builder with Code generation i.e. I would like to:
DSL.fieldByName("BOOK","TITLE")
constructs, I prefer storing name of a table along with it's column names and types like it's shown in Using JOOQ as SQL Builder with Code generation partTableImpl
myself when new table is needed.While digging in manual, I've found how table implementation should look like in chapter Generated tables. However, TableImpl class as well as Table interface should be parameterized with record type and the same goes for TableField class. I believe this is done for easier type inference when directly querying database and retrieving results, though I may be mistaken.
So my questions are:
java.lang.Void
class as type parameter but then I noticed that only subclasses of Record are allowed... The reason is that I don't need record types at all because I plan to use generated by JOOQ
SQL queries in something like Spring JdbcTemplate so mapping is done by myself.Thanks in advance for any help!
Given your use-case, I'm not sure why you'd like to roll your own Table
and TableField
implementations rather than using the ones generated by jOOQ. As you stated yourself, you don't have to regenerate that code every time the DB schema changes. Many users will just generate the schema once in a while and then put the generated artefacts under version control. This will help you keep track of newly added changes.
To answer your questions:
CustomTable
. You may also find some people sharing similar experiences on the user groupYes you can just use Record
. Your minimal custom table type would then be:
class X extends TableImpl<Record> {
public X() {
super("x");
}
}
Note that you will be using jOOQ's internal API (TableImpl
), which is not officially supported. While I'm positive that it'll work, it might break in the future, e.g. as the super constructor signature might change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With