Wrong detected type for MIN operator - I think? [message #1852478] |
Tue, 17 May 2022 17:08  |
Eclipse User |
|
|
|
I am experiencing a problem with the mapping of database types to java types.
I have an JPQL expression with a MIN(DATE) expression - where the DATE is a java type Instant (as are all dates in my application). I then have an attribute converter for Instant<>LocalDataTime and this works for all other dates than the one inside the MIN expression.
What I can see happen is that for all "normal" occurences of dates in the JPQL, Eclipselink correctly identifies their Java return type to LocalDateTime, and then this gets further converted to Instant in my converter.
But for the data inside the MIN expression, Eclipselink identifies "Instant" as the java return type, and due to the logic in DataBaseAccessor#getObjectThroughOptimizedDataConversion the value from the query ends up being a TimeStamp (instead of a LocalDateTime) which then fails with a class cast exception in my AttributeConverter because it expects LocalDateTimes.
This is a bit of a hard problem to explain - I hope the above made sense, and that someone can help me - or at least point me in some meaningful direction!
Thanks!
|
|
|
Re: Wrong detected type for MIN operator - I think? [message #1854240 is a reply to message #1852478] |
Mon, 08 August 2022 14:00  |
Eclipse User |
|
|
|
First, is there any reason you are using/expecting a LocalDateTime instance instead of just using java.sql.Timestamp from the driver?
Do you have the flow down when you use DATE is returned and passed to your converter - specifically how it gives your AttributeConverter a LocalDateTime instance instead of a TimeStamp? I suspect it is just getting a Timestamp and going through the conversion manager to call "((java.sql.Timestamp) sourceObject).toLocalDateTime().toLocalDate();" on it to get the LocalDateTime from it for your converter; if so, you might be better off just using a converter directly from Timestamp <->instance, but I don't remember specifics behind time usage.
What version of EclipseLink are you using?
Best Regards,
Chris
|
|
|
Powered by
FUDForum. Page generated in 0.04367 seconds