Hi Lukas,
Ok! I see your point: it makes sense like that (otherwise, you'll have to
explicitely use "table-like" objects everytime you reference a field).
We did our own little strict getValue (as static method) and so we have a
workaround.
Thanks for the explanation.
cheers!
stan.
On Friday, March 7, 2014 12:26:08 PM UTC+1, Lukas Eder wrote:
>
> Hello Stan,
>
> The main reason for today's functionality is the use of typesafety, which
> is available through the <T> type in Field<T>. This is particularly useful
> when dereferencing a Field from a derived table without knowing the derived
> table's actual name:
>
>
> System.out.println(table(select(AUTHOR.ID)).as("x").field(AUTHOR.ID));
> System.out.println(table(select(AUTHOR.ID)).field(AUTHOR.ID));
>
> The above will print
>
>
> "x"."ID"
> "alias_42068353"."ID"
>
>
> Do note that even if you don't give an alias to your derived tables, jOOQ
> will do that for you as many SQL dialects require aliases on derived tables.
> The suggestion that has been made before was to restrict this
> "convenience" only to the actual column from an aliased table, to prevent
> the confusion you have run into. I.e.
>
> table(select(AUTHOR.ID)).field(AUTHOR.ID); // This will return
> "alias_42068353"."ID"
> table(select(AUTHOR.ID)).field(BOOK.ID); // This should return null
>
>
> A related issue is this one here:
> - https://github.com/jOOQ/jOOQ/issues/2501
> -
> https://groups.google.com/forum/#!searchin/jooq-user/2501/jooq-user/zibf1EmQdp8/8bDkIrLiRvQJ
>
> Given your feedback, and Adam's at the time, I think we should implement
> this for the next major release 3.4.0. I'm not quite sure if this should be
> merged to patch releases, though, as users might have built upon this
> "functionality"
>
> Cheers
> Lukas
>
> 2014-03-06 16:33 GMT+01:00 Stanislas Nanchen
> <[email protected]<javascript:>
> >:
>
>> Hi everyone,
>>
>> We have the following situation : a table A with a field named ID and a
>> table B also with a field named ID.
>> We would have expected an Exception in the following pseudo code
>>
>> {code}
>> ARecord record = selectFrom(A).fetch();
>> Long id = record.getValue(B.ID);
>> {code}
>>
>> However, Jooq tries to match the field with names instead of "strictly"
>> considering the Field itself.
>> (We would have expected the matching behavior with
>> Record#getValue(String), but not with Record#getValue(Field))
>>
>> How can we have a "strict" behavior?
>>
>> Thanks,
>> Cheers,
>> stan.
>>
>>
>>
>> --
>> 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] <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
--
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.