eclipselink icon indicating copy to clipboard operation
eclipselink copied to clipboard

Function ceiling, floor, and round return wrong types

Open hantsy opened this issue 2 years ago • 4 comments

Glassfish 7.0.0-M7 + Built-in Derby Database Java 17 Windows 10

I have tried to refresh my JPA 3.1 examples and test functionalities against the newest Glassfish 7.0.0 M7.

The Person salary property is a BigDecimal. But the result is a Double, obviously it is not my expected.

cb.ceiling(root.get("salary")),
                    cb.floor(root.get("salary")),
                    cb.round(root.get("salary"), 1),

hantsy avatar Aug 09 '22 15:08 hantsy

This may be caused by many things. DB native function is being invoked in most of the cases, but Derby is a special case here. It does not support some of the functions defined in the spec so they are emulated using math expressions. See DerbyPlatform.java Line 474 This may be the cause of type change. I can verify whether return type of the expression is set properly for those functions.

Tomas-Kraus avatar Aug 15 '22 11:08 Tomas-Kraus

Also make sure that you are using latest shapshot build of EclipseLink. It was not updated in GF yet.

Tomas-Kraus avatar Aug 15 '22 11:08 Tomas-Kraus

I was using Glassfish 7.0 M7 built-in EclipseLink.

hantsy avatar Aug 16 '22 13:08 hantsy

I forced return type to follow number argument in CriteriaBuilderImpl functions definitions. Also added jUnits to verify returned type for ceiling, floor and round functions.

Tomas-Kraus avatar Aug 19 '22 12:08 Tomas-Kraus