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=?)