-->
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: Is a property with the name 'id' not allowed?
PostPosted: Wed Mar 16, 2005 5:51 pm 
Beginner
Beginner

Joined: Tue Mar 08, 2005 5:32 pm
Posts: 20
Location: USA
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=?)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 16, 2005 6:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
you will get problems when you name a non-id property "id", as "id" is a reserved word in HQL and always means the id-property.


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.