Thanks for your message.
A Record's row type isn't defined by the attributes it contains. Imagine if
that were the case, would we have to map to jOOQ's internal
org.jooq.impl.AbstractRecord.changed or other properties, for example? No,
an org.jooq.Record extends org.jooq.Fields, and thus defines exactly what
fields are contained in it. As such, you cannot extend generated records
and add more fields to them.
The idea looks hackish anyway. Why extend something that is well defined,
rather than use composition? Why not write:
public class MyDto {
// Or, whatever:
MyTableRecord theRecord;
int additionalAttribute1;
}
Doesn't that look much cleaner?
On Wed, Apr 5, 2023 at 11:25 PM '[email protected]' via jOOQ User Group
<[email protected]> wrote:
> I stumble from time to time over the following problem: I want to map the
> result of a query into a DTO. The DTO should be derived from an updateble
> record generated by the code generator and extended by a few additional
> attributes.
>
> public class MyDto extends MyTableRecord {
> private int additionalAttribute1;
> }
>
> With the query
> jooq.select(MyTableRecord.fields())
> .select(ANOTHER_TABLE.ANOTHER_FIELD.as("additionalAttribute1")
> .join(ANOTHER_TABLE).on(...)
> .fetchInto(MyDto.class)
>
> only the properties defined in the MyTableRecord are mapped and returned,
> not the additionalAttribute1 ? Why is this and how can I solve this ?
>
> Kind regards
> Dominik
>
> --
> 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].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/ac029a24-ce7b-4d76-931f-cc0b486e636dn%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/ac029a24-ce7b-4d76-931f-cc0b486e636dn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jooq-user/CAB4ELO7o5CowLzDwbdTDUokJAbGztix5YWbbxT78SPdwN_fu3A%40mail.gmail.com.