On my entity class I have the following filter definitions:
@FilterDefs({ @FilterDef(name="courseStartsBetween", parameters = { @ParamDef(name="startDateTime", type="LocalDateTime"), @ParamDef(name="endDateTime", type="LocalDateTime") }) }) @Filters({ @Filter(name="courseStartsBetween", condition="scope_id NOT IN (select scope_id FROM course_time_slot WHERE course_time_slot.end_date_time < :startDateTime OR course_time_slot.start_date_time > :endDateTime)") })
Based on the Hibernate documentation, LocalDateTime
is a valid BasicTypeRegistry key for Java 8's LocalDateTime
objects, and the type is mapped just fine. When I now enable the filter as follows:
requestContainer.entityManager().unwrap(Session.class) .enableFilter("courseStartsBetween") .setParameter("startDateTime", septemberFirst.atStartOfDay()) .setParameter("endDateTime", septemberFirst.plus(1, ChronoUnit.YEARS).atStartOfDay());
The query fragment get's properly embedded in the query (show-sql enabled), but then the query fails with:
Caused by: org.postgresql.util.PSQLException: ERROR: operator does not exist: timestamp without time zone > bigint Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts. Position: 4114 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310) ~[postgresql-9.4.1209.jar:9.4.1209] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2023) ~[postgresql-9.4.1209.jar:9.4.1209] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:217) ~[postgresql-9.4.1209.jar:9.4.1209] at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:421) ~[postgresql-9.4.1209.jar:9.4.1209] at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:166) ~[postgresql-9.4.1209.jar:9.4.1209] at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118) ~[postgresql-9.4.1209.jar:9.4.1209] at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:71) ~[hibernate-core-5.2.10.Final.jar:5.2.10.Final] ... 55 common frames omitted
This is unexpected as my fields map to the timestamp
type (which it also should according to the above referenced documentation). How should I map a LocalDateTime
type in a FilterDef
?
0 comments:
Post a Comment