Hi all
I have found something strange using filters, I write that to put some light on it.
I need to filter the data that user views by using a criteria that limits the type, something
like do a "select from Cars" using a filter
Code:
hibernate.cfg.xml:
<filter-def name="CarColor">
<filter-param name="colors" type="string" />
</filter-def>
somewhere in car.hbm.xml:
<filter condition="COLOR in (:colors)" name="CarColor"/>
It works fine, at the begining, but the problem arises when you first use
that filter with three colors, and afer, in other place of the application, with
six colors, looks that the number of params is shared between querys and
I end with errors like that:
Code:
ERROR - org.hibernate.util.JDBCExceptionReporter - Falta el parámetro IN o OUT en el índice:: 14
INFO - org.hibernate.type.StringType - could not bind value 'XX' to parameter: 14; Índice de columna no válido
WARN - org.hibernate.util.JDBCExceptionReporter - SQL Error: 17003, SQLState: 99999
ERROR - org.hibernate.util.JDBCExceptionReporter - Índice de columna no válido
I solved it using a trick, if the maximun number of colors is 10, then the filter always has 10 params,
the colors i want to filter and some more to fill the 10. It is not smart but works.
So I share it here to common known.