I'm suffering the same problem right now and it does look very much like Hibernate is using a cached version of the resulting SQL for the filter rather than re-generating the code.
My problem is pretty similar to yours as described, using an "IN" directive in a filter but changing the number of parameters in the associated parameter list. Once the filter has been activated once it is holding on to the SQL that was generated and then re-using it indefinately. It takes a restart of the application to reset the filter.
I've spent most of the afternoon searching for a solution and can't find one. This looks very much like a bug to me.
I've decided to work around this by using a number of parameters instead of a single "IN" statement. I've posted my work around filter definition here just in case you've not thought of this already and it's of any help.
Code:
@FilterDef(name="ranks", parameters={
@ParamDef(name="rankCode0", type="java.math.BigDecimal"),
@ParamDef(name="rankCode1", type="java.math.BigDecimal"),
@ParamDef(name="rankCode2", type="java.math.BigDecimal"),
@ParamDef(name="rankCode3", type="java.math.BigDecimal"),
@ParamDef(name="rankCode4", type="java.math.BigDecimal"),
@ParamDef(name="rankCode5", type="java.math.BigDecimal"),
@ParamDef(name="rankCode6", type="java.math.BigDecimal"),
@ParamDef(name="rankCode7", type="java.math.BigDecimal"),
@ParamDef(name="rankCode8", type="java.math.BigDecimal"),
@ParamDef(name="rankCode9", type="java.math.BigDecimal")
}, defaultCondition="(LABOURGRADECODE = :rankCode0 OR LABOURGRADECODE = :rankCode1 OR LABOURGRADECODE = :rankCode2 OR LABOURGRADECODE = :rankCode3 OR LABOURGRADECODE = :rankCode4 OR LABOURGRADECODE = :rankCode5 OR LABOURGRADECODE = :rankCode6 OR LABOURGRADECODE = :rankCode7 OR LABOURGRADECODE = :rankCode8 OR LABOURGRADECODE = :rankCode9)")
The code above always matches 10 rankCode parameters. I set however many I have, and the remainder are set to unsed values (in this case -1). For instance rankCode0 set to 12345 and rankCode1 through to rankCode9 set to -1.
If anyone has a more workable solution that would be great.