-->
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: Can I use 'id' as property name
PostPosted: Mon Oct 30, 2006 6:28 pm 
Newbie

Joined: Tue Oct 17, 2006 2:50 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hello everyone,
I am trying to map a class to a database.
Class DeviceID {
String id;
String domain;
}
mapping file:
<class name="DeviceID" table="device_id">
<id name="pk_id" type="long" column="pk_id" access="field">
<generator class="native" />
</id>
<property name="id" type="string" column="device_id" access="field" length="50"/>
<property name="domain" type="string" column="domain" length="50" access="field"/>
</class>

I can insert DeviceIDs into device_id table. while when trying to get DeviceID from table. using
select d from com.gehc.device.model.DeviceID d
where d.id = :id and d.domain = :domain

Hibernate always maps DeviceID.id to pk_id column:
select
deviceid0_.pk_id as pk1_0_,
deviceid0_.dev_id as dev2_0_,
deviceid0_.domain as domain0_
from
device_id deviceid0_
where
deviceid0_.pk_id=?
and deviceid0_.domain=?
INFO - could not bind value 'id1' to parameter: 1

Is there any way to solve this problem?

Thanks you very much.

young


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 30, 2006 7:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
In HQL the 'id' token is a reserved word. Its action is to refer to the primary key.
There are others such as 'size' and others.


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.