We have some custom types that reflected to multiple db fields. For example
PersonName{
String salutation,
String firstName,
String lastName
}
stored as 3 separate db fields. And it's boring to always write
db.select(PERSON.FIRST_NAME, PERSON.LAST_NAME, PERSON.SALUTATION, ... some other fields)
then fetch the record and create PersonName type from the appropriate record fields.
The idea is to define some multi-column custom field PERSON_NAME
, which will be expanded by jooq into three "real" fields during the query execution, and packed to the one PersonName
object in the result.
Looks like it's possible to do something like this with org.jooq.impl.AbstractField
, but I'm wondering, may be there is a solution for such case already.
There are pending feature requests to support this kind of functionality:
With out-of-the-box functionality of jOOQ 3.6, you could store those columns somewhere as:
And then select them as such: