Blazebit / blaze-persistence

Rich Criteria API for JPA providers
https://persistence.blazebit.com
Apache License 2.0
697 stars 85 forks source link

Exception thrown when using LocalDate in an EntityView being fetched using the Multiset strategy #1904

Open dsarlo opened 2 weeks ago

dsarlo commented 2 weeks ago

Description

When using the Multiset fetch strategy on a collection whose entity view contains a LocalDate typed value, an exception is thrown when attempting to convert the database column to a java.sql.Timestamp before converting to a LocalDate.

Expected behavior

The database column for a LocalDate should be converted from a java.sql.Date instead of a java.sql.Timestamp object.

Actual behavior

java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]
    at java.sql/java.sql.Timestamp.valueOf(Timestamp.java:196)
    at com.blazebit.persistence.view.impl.type.LocalDateBasicUserType.fromString(LocalDateBasicUserType.java:36)
    at com.blazebit.persistence.view.impl.type.LocalDateBasicUserType.fromString(LocalDateBasicUserType.java:30)
    at com.blazebit.persistence.view.impl.objectbuilder.transformer.MultisetTupleTransformer.transform(MultisetTupleTransformer.java:78)
    at com.blazebit.persistence.view.impl.objectbuilder.transformator.TupleTransformator.transform(TupleTransformator.java:84)
    at com.blazebit.persistence.view.impl.objectbuilder.transformator.TupleTransformator.transform(TupleTransformator.java:77)
    at com.blazebit.persistence.view.impl.objectbuilder.ChainingObjectBuilder.build(ChainingObjectBuilder.java:51)
    at com.blazebit.persistence.impl.builder.object.PreProcessingObjectBuilder.build(PreProcessingObjectBuilder.java:46)
    at com.blazebit.persistence.impl.query.ObjectBuilderTypedQuery.getResultList(ObjectBuilderTypedQuery.java:71)
    at com.blazebit.persistence.impl.query.ObjectBuilderTypedQuery.getSingleResult(ObjectBuilderTypedQuery.java:49)  

Steps to reproduce

Introduce a collection on an entity view that uses the Multiset fetch strategy whose entity view contains a LocalDate field

Environment

Version: 1.6.11
JPA-Provider: hibernate DBMS: postgres 13.3 Application Server: tomcat