Hello,
I'm trying to run a simple hql which searches by a byte[] field :
"from Ci c where c.refId=?"
but query does not return saved object.
The Ci object is stored before with the refId attribute set to (new byte[]{1,2,3}) value. When the same refId value is used in hql the object is not returned. The hql is invoked by find() method listed below.
Any info is greately appreciated.
Thanks,
Alex
--------------------------------------------
Hibernate version:
3.0
Table Schema:
create table cis (
id varchar(32) not null,
name varchar(255),
ref_id VARBINARY(16) not null unique,
customerId integer,
description varchar(255),
is_removed bit,
type varchar(255),
primary key (id)
);
Mapping documents:
<hibernate-mapping>
<class name="Ci" table="cis">
<id name="id" column="id" type="java.lang.String" length="32" unsaved-value="null">
<generator class="uuid.hex"/>
</id>
<property name="name" type="string" column="name"/>
<property name="refId" type="serializable" column="ref_id" length="16" not-null="true" unique="true"/>
<property name="customerId" type="int" column="customerId"/>
<property name="description" type="string" column="description"/>
<property name="removed" type="boolean" column="is_removed"/>
<property name="type" type="string" column="type"/>
</class>
</hibernate-mapping>
Code for executing hql:
public List find(final String queryString, final Object[] values) throws DataAccessException
{
return (List) getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
Query queryObject = session.createQuery(queryString);
if (values != null) {
for (int i = 0; i < values.length; i++) {
queryObject.setParameter(i, values[i],Hibernate.SERIALIZABLE);
}
}
return queryObject.list();
}
}, true);
}
Name and version of the database you are using:
MySql 4.1
The generated SQL (show_sql=true):
Hibernate: select ci0_.id as id, ci0_.name as name3_, ci0_.ref_id as ref3_3_, ci0_.customerId as customerId3_, ci0_.description as descript5_3_, ci0_.is_removed as is6_3_, ci0_.type as type3_ from cis ci0_ where (ci0_.ref_id=?)
Debug level Hibernate log excerpt:
Debug
|