I am trying to map a LocalDate to a SQL Date, but am receiving this error:
java.lang.IllegalArgumentException: Undefined filter parameter [afterDateLocal]
I can’t provide a reproducible example, but here’s the code of the ListingRepositoryImpl:
if (!queries.get("checkInDate").get(0).equals("undefined")) { Filter afterDateFilter = session.enableFilter("afterDateFilter"); String afterDate = queries.get("checkInDate").get(0); LocalDate afterDateLocal = LocalDate.parse(afterDate); System.out.println("After date: " + afterDateLocal); afterDateFilter.setParameter("afterDateLocal", afterDateLocal); } else { session.disableFilter("afterDateFilter"); }
And the filters defined on the entity listing:
@Entity @Table(name="listing") @FilterDefs({ @FilterDef(name="priceFilter", parameters=@ParamDef(name="priceComparison",type="double")), @FilterDef(name="beforeDateFilter", parameters=@ParamDef(name="beforeDateLocal", type="date")), @FilterDef(name="afterDateFilter", parameters=@ParamDef(name="afterDateLocal", type="date")) }) @Filters({ @Filter(name="priceFilter", condition="price <= :priceComparison"), @Filter(name="beforeDateFilter", condition=":beforeDateLocal <= date"), @Filter(name="afterDateFilter", condition=":afterDateLocal >= date") })
I am using Hibernate 5.5.7 so I expect LocalDate to work.
Advertisement
Answer
date
was not defined in the database, which is why I received the error.