2013/9/2 Dan <[email protected]>

> It would be great if it were easy to have a Record implementation that
> delegated to another, especially for the generated record classes.
>
> Example use case 1: I have a record that maps to a few rows joined
> together from 2-3 tables. I can set fields on it using the (verbose)
> non-typesafe methods, but it would be great to use generated setFoo(),
> setBar(), etc methods. I can't go record.into(FirstTable.class).setFoo()
> because that creates a copy - it would be great if I could easily go
> FirstTable.wrap(record).setFoo(x) and have that setFoo() method delegate to
> the underlying wrapped record, SecondTable.wrap(record).setBar(y) affects
> the same record, and so on.
>

Yes, these kinds of one-to-one relations would often be useful if known to
jOOQ. There had been quite a few discussions around this subject in the
recent past. Currently, jOOQ does not add such cleverness to records.
However, if your join product is guaranteed to be "updatable", why not just
create a database view and make these things transparent to jOOQ?


> Example use case 2: Disambiguate fields. If I go dsl.select()... with some
> joins, and the table field names clash, jooq / sql will not complain
> because when generating the SQL jooq disambiguates the field names with
> tables. However in the returned records, it seems that table names are
> ignored and whatever fields came last clobber earlier fields (usually one
> would prefer the other way round, but that's not 100% of the time either).
>

That shouldn't be the case. If you have an exact match of table name /
field name, you should get the right value, even if field names clash. Can
you provide a test case to reproduce the issue?


> Being able to get a specific "view" of the record would again be very
> helpful, e.g.  FooTable.wrap(record).getId() vs
> BarTable.wrap(record).getId(). Of course that doesn't disambiguate the case
> of table aliasing but that should be easily handled with modest extensions
> to this concept.  I think this would be more convenient than being forced
> to explicitly list all the fields to select() and aliasing the clashing
> ones.
>

There's
http://www.jooq.org/javadoc/latest/org/jooq/Record.html#into(org.jooq.Table),
instead of Table.wrap(Record). Does this help?

Cheers
Lukas

-- 
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/groups/opt_out.

Reply via email to