-->
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.  [ 2 posts ] 
Author Message
 Post subject: Problem with HQL query
PostPosted: Wed Mar 16, 2005 3:58 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
I have an identifier called sysID that is automatically generated by the database. I have a property called id. This is my HQL:

Query query = session.createQuery("select v from CLVariable as v where v.id=:variableID");
query.setInteger("variableID", variableID);

The problem is that it returning a results that have sysID=varaibleID and not id=varaiableID.

A similar query works fine for the property name.

Any suggestions would be highly appreciated.

Thanks

Hibernate version: 3.0rc1

Mapping documents:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="com.businessEntities.CLVariable" table="VMD_VARIABLE" lazy="true">

<id name="sysID" type="integer" column="SYS_VMD_VARIABLE_ID" unsaved-value="0">
<generator class="identity"/>
</id>

<timestamp name="timestamp" column="VMD_VAR_TIMESTAMP"/>

<property name="id" type="integer" column="VARIABLE_ID"/>
<property name="name" type="string" column="VARIABLE_NAME"/>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

CLVariableDAO varDAO = new CLVariableDAO();
varDAO.getVariableList(1);
HibernateUtil.commitTransaction();
HibernateUtil.closeSession();

NOTE: HibernateUtil is the class from http://caveatemptor.hibernate.org

Name and version of the database you are using:
DB2 UDB 8.1

The generated SQL (show_sql=true):
[3/16/05 14:25:32:972 EST] 30674e5 SystemOut O Hibernate: select clvariable0_.SYS_VMD_VARIABLE_ID as col_0_0_ from UA_RULE.VMD_VARIABLE clvariable0_ where (clvariable0_.SYS_VMD_VARIABLE_ID=?)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 6:20 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
This is discused in more detail here:
http://forum.hibernate.org/viewtopic.php?t=940066


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

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.