-->
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: Use of hibernate serializable type in HQL where clause
PostPosted: Wed Jan 10, 2007 8:38 am 
Newbie

Joined: Wed Jan 10, 2007 8:07 am
Posts: 2
Hibernate version: 3.2.0

Name and version of the database you are using: Oracle 9i

I'm having problems using a serializable in the where clause of an HQL statement. My HQL statement is:

Code:
from service.valueobjects.AttributeVO attribute where attribute.value = :value

where the value parameter is being set to an arbitrary java.lang.Serializable.

When I execute the query, I get a
Code:
ORA-00997: illegal use of LONG datatype
SQL exception back.

The actual SQL being generated is as follows:

Code:
select attributev0_.id as id0_, attributev0_.name as name0_, attributev0_.value as value0_, attributev0_.group_definition_id as group4_0_ from Attribute attributev0_ where attributev0_.value=?


This seems to be where the problem lies - the concept of equals for a Serializable is not implemented in the underlying database - it has to be tested in the Java layer. The documentation (http://www.hibernate.org/hib_docs/refer ... ryhql.html) is silent on the subject of what types can and can't be used in where clause expressions. Am I right in assuming that this use is unsupported? Is my best option to retrieve all the persisted AttributeVO object, and then perform an equality test on the value property myself?

For reference, here is the mapping for the AttributeVO class:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="service.valueobjects">
   <class name="AttributeVO" table="Attribute" lazy="false">
      <id name="id" column="id" type="long" access="field">
         <generator class="sequence">
            <param name="sequence">attribute_id_seq</param>
         </generator>
      </id>
      <property name="name" type="string" length="255" not-null="false" lazy="false"/>
      <property name="value" type="serializable" not-null="false" lazy="false"/>
      <many-to-one name="groupDefinition" column="group_definition_id" class="GroupDefinitionVO" not-null="true"/>
   </class>
</hibernate-mapping>


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.