Hi Peter,

Yes, for your specific case, you're lucky. You can use Record.into(Table):
http://www.jooq.org/javadoc/latest/org/jooq/Record.html#into(org.jooq.Table)

It maps an arbitrary record onto another record type, given a table. In
other words, the two statements are similar:

// Using into()
SiteRecord site = joinedRecord.into(SITE);

// Manually moving values:
SiteRecord site = sql.newRecord(SITE);
// [ copy all relevant values from joinedRecord to site ]
// [ transferring "changed" state from joinedRecord to site ]

If you can guarantee primary key integrity, you can also modify and store /
delete the SiteRecords, etc.

Beware that joining may produce ambiguities, if several tables contain the
same column names.
Beware that renaming columns may keep Record.into(Table) from working
properly

Cheers
Lukas


2013/1/9 Peter Ertl <[email protected]>

> we all know mapping a single table into a pojo-style record works:
>
>   Result<SiteRecord> records = sql.selectFrom(SITE).fetch();
>
> also we know this works when joining tables:
>
>   Result<Record> joinedRecords =
> sql.select().from(SITE).leftOuterJoin(ACCOUNT).onKey().fetch();
>
> Since there is already logic for mapping fields into type-safe records,
> would this orm-style of mapping be possible?
>
> for (Record joinedRecord : joinedRecords) {
> SiteRecord site = joinedRecord.getRecord(SiteRecord.class);
> AccountRecord account = joinedRecord.getRecord(AccountRecord.class);
> // bla
> }
>
> Regards,
> Peter
>

Reply via email to