Hello,

2015-07-01 10:56 GMT+02:00 jdoe <[email protected]>:

> Whenever I use coerce I experience casting errors:
>
>
> Map<Long, Bean1> map = create
>         .fetch(TABLE1)
>         .intoMap(TABLE1.TABLE_ID.cast(Long.class), Bean1.class);
>
>
> If TABLE1.TABLE_ID has type ULong the map will have ULong as its keys, 
> ignoring coercion.
>
> Very confusing behavior!
>
> Indeed. This is a bug as can be seen in the implementation of
ResultImpl.intoMap():

    @Override
    public final <K, E> Map<K, E> intoMap(Field<K> key, RecordMapper<?
super R, E> mapper) {
        return intoMap0(indexOrFail(fieldsRow(), key), mapper);
    }

This implementation does not enforce the DataType from the key argument
upon the result. I have registered an issue for this:
https://github.com/jOOQ/jOOQ/issues/4403


> How do I get exactly Map<Long, Bean1>, not Map<ULong, Bean1>?
>
>
There are several workarounds:

1. Fetch a Long type instead of the ULong type by using an explicit SELECT
statement
2. Collect the map manually
3. Avoid using ULong in the code generator by turning it off via the
<unsignedTypes/> flag

I would suggest 3), in case ULong is bothering you too often...

Hope this helps,
Lukas

2015-07-01 10:56 GMT+02:00 jdoe <[email protected]>:

> Whenever I use coerce I experience casting errors:
>
>
> Map<Long, Bean1> map = create
>         .fetch(TABLE1)
>         .intoMap(TABLE1.TABLE_ID.cast(Long.class), Bean1.class);
>
>
> If TABLE1.TABLE_ID has type ULong the map will have ULong as its keys, 
> ignoring coercion.
>
> Very confusing behavior!
>
> How do I get exactly Map<Long, Bean1>, not Map<ULong, Bean1>?
>
>  --
> 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.

Reply via email to