Cannot index java.util.Date property when the value is a java.sql.Date

Description

java.sql.Date does not implement toInstant, which is used by the java.util.Date bridge. So we get this:

1 2 3 java.lang.UnsupportedOperationException at java.sql.Date.toInstant(Date.java:304) at org.hibernate.search.mapper.pojo.bridge.builtin.impl.DefaultJavaUtilDateValueBridge.toIndexedValue(DefaultJavaUtilDateValueBridge.java:26)

This is a huge problem, because ORM will definitely put a java.sql.Date value in a java.util.Date property annotated with @Temporal(TemporalType.DATE) when loading from the database, and then entity reindexing will fail.

We should probably implement DefaultJavaUtilDateValueBridge exactly as DefaultJavaSqlDateValueBridge to avoid any problem.

And also we should add a test case (maybe add a few java.sql.Date instances in JavaUtilDatePropertyTypeDescriptor).

We probably have a similar problem for java.sql.Time, and maybe also for java.sql.Timestamp (maybe not for the last one, but it doesn't hurt to test).

Environment

None

Status

Assignee

Fabio Massimo Ercoli

Reporter

Yoann Rodière

Labels

None

Suitable for new contributors

None

Feedback Requested

None

Fix versions

Affects versions

6.0.0.Alpha9

Priority

Major
Configure