Hibernate version: 3.2.6.GA
Hibernate Annotations version: 3.3.0.GA
I am successfully using a FilterDef and Filter with an integer parameter type. Now I need to filter a collection with an IN clause. I don't know how to define the type on the @ParamDef annotation. If I do the following:
Code:
@FilterDef(name = "pollutantFilter", parameters = {@ParamDef(name = "codes", type = "string[]")})
I get this error: java.lang.IllegalArgumentException: Undefined filter parameter [codes]
If I make the type just "string", then I get this error:
java.lang.IllegalArgumentException: Incorrect type for parameter [codes]
Here is my filter:
Code:
@org.hibernate.annotations.Filter(name = "pollutantFilter",
condition = "POLLUTANT_CD in {:codes}")
I want to use it like this: getPollutantCodes() returns String[].
Code:
Filter hfilter = getSession().enableFilter("pollutantFilter");
hfilter.setParameter("codes", getPollutantCodes());
The SQL is simple. How can I get Hibernate to do it? Thanks.