Hibernate version: 3.1rc2
I have some query trouble. I have a query where my parameter is list of Long's.
Anyway here the query:
from Holiday h where h.type = :calendarType and h.year in (:calendarYears)
and here is the SQL it generates:
Code:
select
holiday0_.id as id14_,
holiday0_.version as version14_,
holiday0_.calendar as calendar14_,
holiday0_.hol_date as hol4_14_,
holiday0_.year as year14_,
holiday0_.description as descript6_14_
from holidays holiday0_ where holiday0_.calendar=? and
(holiday0_.year in (?))
which is correct.
here is a portion of the traces with debug ON that shows that list does exists:
Code:
org.hibernate.impl.SessionImpl find: from Holiday h where h.type = :calendarType and h.year in (:calendarYears)
org.hibernate.util.SerializationHelper Starting serialization of object [[2005, 2006]]
org.hibernate.engine.QueryParameters named parameters: {calendarType=O, calendarYears=2c6d8085f3f28093eae1f6e1aef5f4e9ecaec1f2f2e1f9cce9f3f4f801529d1947e11d838081c98084f3e9fae5f8f080808082f7848080808af3f2808eeae1f6e1aeece1eee7aeccefeee7bb0b64104c0fa35f828081ca8085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808080808755f3f180fe80828080808080808756f8}
org.hibernate.hql.ast.QueryTranslatorImpl compile() : The query is already compiled, skipping...
org.hibernate.jdbc.AbstractBatcher about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
org.hibernate.SQL select holiday0_.id as id14_, holiday0_.version as version14_, holiday0_.calendar as calendar14_, holiday0_.hol_date as hol4_14_, holiday0_.year as year14_, holiday0_.description as descript6_14_ from holidays holiday0_ where holiday0_.calendar=? and (holiday0_.year in (?))
Hibernate: select holiday0_.id as id14_, holiday0_.version as version14_, holiday0_.calendar as calendar14_, holiday0_.hol_date as hol4_14_, holiday0_.year as year14_, holiday0_.description as descript6_14_ from holidays holiday0_ where holiday0_.calendar=? and (holiday0_.year in (?))
org.hibernate.jdbc.AbstractBatcher preparing statement
org.hibernate.loader.Loader bindNamedParameters() O -> calendarType [1]
org.hibernate.type.StringType binding 'O' to parameter: 1
org.hibernate.loader.Loader bindNamedParameters() [2005, 2006] -> calendarYears [2]
org.hibernate.util.SerializationHelper Starting serialization of object [[2005, 2006]]
org.hibernate.type.SerializableType binding '2c6d8085f3f28093eae1f6e1aef5f4e9ecaec1f2f2e1f9cce9f3f4f801529d1947e11d838081c98084f3e9fae5f8f080808082f7848080808af3f2808eeae1f6e1aeece1eee7aeccefeee7bb0b64104c0fa35f828081ca8085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808080808755f3f180fe80828080808080808756f8' to parameter: 2
org.hibernate.util.SerializationHelper Starting serialization of object [[2005, 2006]]
org.hibernate.jdbc.AbstractBatcher about to open ResultSet (open ResultSets: 0, globally: 0)
org.hibernate.loader.Loader processing result set
org.hibernate.loader.Loader done processing result set (0 rows)
org.hibernate.jdbc.AbstractBatcher about to close ResultSet (open ResultSets: 1, globally: 1)
org.hibernate.jdbc.AbstractBatcher about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
org.hibernate.jdbc.AbstractBatcher closing statement
org.hibernate.loader.Loader total objects hydrated: 0
org.hibernate.engine.StatefulPersistenceContext initializing non-lazy collections
org.hibernate.transaction.JDBCTransaction commit
org.hibernate.impl.SessionImpl automatically flushing session
but for some reason Hibernate tries to serialize the list and binds the serialized string to calendarYears. As shown in trace above like this:
Code:
{calendarType=O, calendarYears=2c6d8085f3f28093eae1f6e1aef5f4e9ecaec1f2f2e1f9cce9f3f4f801529d1947e11d838081c98084f3e9fae5f8f080808082f7848080808af3f2808eeae1f6e1aeece1eee7aeccefeee7bb0b64104c0fa35f828081ca8085f6e1ecf5e5f8f28090eae1f6e1aeece1eee7aecef5ede2e5f2062c159d8b14600b828080f8f08080808080808755f3f180fe80828080808080808756f8}
That of course returns 0 sized result which is not correct.
So how do I do it?
Thanks,
Alex.