I have an object with properties sysID and id. I am used sysID as an Hibernate identifier and id as a regular variable.
When I try a query like :"select v from CLVariable as v where v.id=1"
It gives me no results although the database has a variable with id=1
When I try a query like : "select v from CLVariable as v where v.id=4"
It gives me a result where sysID=4
When I try a query like : "select v from CLVariable as v where v.sysID=4"
It gives me a result where sysID=4
This is puzzling me very much. Is a property like this not allowed:
<property name="id" type="integer" column="VARIABLE_ID"/>
Thanks for looking
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=?)