Hi Joe, Thank you very much for reporting this. That's a very interesting edge case that arises from the fact that jOOQ:
- Calls all applicable "setters" according to the specification of the DefaultRecordMapper, in no particular order - Accepts both JavaBeans compliant setters (setId() for the ID column) as well as "jOOQ style" setters (setId() or SET_ID() for the SET_ID column) In a way, this "works as designed", even if in this particular case, it's obvious that the design is flawed. We'll have to fix this in a future minor release, by adding some flags that allow for turning off either one of the above "setter" styles: https://github.com/jOOQ/jOOQ/issues/6870 Until then, workarounds include: - Renaming columns as you've noticed - Working around this particular issue on a per-table and per-into() call basis - Implementing your own mapper and registering that as a RecordMapperProvider [1] I hope this helps, Lukas [1]: https://www.jooq.org/doc/latest/manual/sql-execution/fetching/pojos-with-recordmapper-provider 2017-11-25 14:17 GMT+01:00 <[email protected]>: > I have some tables that are used to model multiple sets of things. They > are roughly > > table sets (set_id, ...some stuff about the sets) > table set_contents(id, set_id, some stuff about the items) > > I generate Record and a Pojo classes from the tables. These generate > getters and setters for the 'id' and 'setId' fields for set_contents. > > When calling SetContentsRecord.into(SetContents.class) , the mapper seems > to recognise both setId(long) and setSetId(long) as setters for the > SetContents pojo, so the mapping breaks down. > > For example, a record > > SetContentsRecord(000, 111) > > gets mapped to a pojo > > SetContents(111, 111) > > since the id is first set to 000, then 111 is copied into both the id and > the set_id fields. > > It kinda makes sense that the mapping code would recognise setId(long) and > setSetId(long) as potential setters for set_id, I guess. > > I'm afraid I don't have any good ideas about what a solution would look > like, or really if this even counts as a bug, since auto mapping is a > pretty dark art. > > For me, I'm going to change my field names, but I thought others might be > interested - it certainly cost me a lot of time :) > > Kind regards, > Joe > > -- > 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. > -- 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.
