I am learning how to work with jooq. I would like to know if I can add some domain level methods to the generated record classes.
Suppose the entry was as follows:
public class ConCalCompanyRecord extends org.jooq.impl.UpdatableRecordImpl<com.aesthete.csmart.connect.model.db.gen.tables.records.ConCalCompanyRecord> implements org.jooq.Record6<java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String, java.sql.Timestamp, java.sql.Timestamp> {
public void isABlueCompany(){
}
}
But I know, if I do this, as soon as I again generate this class from the database, all my changes will be lost. So what is the recommended way to do this?
Shell class? Subclass for writing? If this is any of them, how can I get jooq to recognize these classes during fetching. For instance:
connectionFacade.getDSLContext()
.selectFrom(CON_CAL_INSTANCE)
.where(CON_CAL_INSTANCE.DATE.between(
new Date(datesOfTheWeekForDate[0].toDate().getTime()), new Date(datesOfTheWeekForDate[1].toDate().getTime())))
.orderBy(CON_CAL_INSTANCE.DATE)
.fetch()
.into(new RecordHandler<ConCalInstanceRecord>() {
@Override
public void next(ConCalInstanceRecord record) {
calendarEntries.addToList(new com.aesthete.csmart.connect.model.domain.records.ConCalInstance(record));
}
});
In the above case, I am providing the ConCalInstance wrapper to the record class. Should I write a RecordHandler, like this for every query I execute, if I need to use a wrapper? What is the recommended way to do this?
source
share