-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Query object by byte[] field
PostPosted: Mon May 16, 2005 1:58 pm 
Newbie

Joined: Mon May 16, 2005 1:25 pm
Posts: 9
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.