Hi Samir, I have registered a feature request to generate a mapper() onto generated TableRecords: https://github.com/jOOQ/jOOQ/issues/5412
That's a low hanging fruit. Additional features are certainly possible, but need more discussion, I think. Best Regards, Lukas 2016-07-07 10:35 GMT+02:00 Lukas Eder <[email protected]>: > Hi Samir, > > 2016-07-07 4:50 GMT+02:00 Samir Faci <[email protected]>: > >> 1. One conversion that would be useful to have is the ability to convert >> from POJOs to Records and vice versa. >> >> On occasion I need to roll out my own POJO because our data is >> represented different at the service layer then how the data >> is actually stored, but I find myself using the autogenerated records and >> POJOs a good bit. It would be nice if there was an easy way to going from >> say: >> >> TableNameRecord --> TableName (pojo) and back. >> > > Do I get you right, you'd like a hard-coded method in the generated > TableNameRecord that does the mapping for the generated POJO? E.g. > > > class TableNameRecord extends UpdatableRecordImpl { > ... > public TableNamePojo intoTableNamePojo() { ... } > public void fromTableNamePojo(TableNamePojo pojo) { ... } > } > > > Would this really help? I can definitely see the into() method. The from() > method doesn't seem to add that much value over the existing > Record.from(Object) method, except, perhaps, some additional type safety? > > >> It varies on my use case but I tend to usually fetchInto( . class) and >> most of the the class passed in is either the record or pojo that was >> generated by jooq. >> > > Oh, I see, that's a different story, though. The problem is that > fetchInto(Class) is called on a ResultQuery<R>, where R is a generic type. > It will be a bit harder to find a solution along the lines of what you're > looking for. Perhaps, we could generate a RecordMapper<TableNameRecord, > TableNamePojo>, which would add some type safety over passing the class > literal (and it could be implemented more optimally). That RecordMapper > could then be made available from TableNameRecord: > > class TableNameRecord extends UpdatableRecordImpl { > ... > > public static RecordMapper<TableNameRecord, TableNamePojo> mapper() { > ... } > > } > > > This could then be used as such: > > dsl.select(...).from(...).fetchInto(TableNameRecord.mapper()) > > > What do you think? > -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
