-->
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.  [ 1 post ] 
Author Message
 Post subject: <id> confused for <property name="id">
PostPosted: Wed Oct 18, 2006 9:56 am 
Beginner
Beginner

Joined: Fri Jun 02, 2006 1:23 am
Posts: 27
I'm trying to map a property in my class called "id" to a column in the database which isn't the primary key. When i try to query against this property the sql that gets generated uses the column specified in the <id /> element instead of the column specified in this property.

My mapping file looks like this:
Code:
<class name="LegacyClass" table="SOMETABLE">
  <id name="databaseId" column="ID">
  <property name="id" column="businessId" />
  ...
</class>


I've tried the following criterias,
Code:
sess.createCriteria(Cat.class)
    .add( Restrictions.eq( "id", businessId ) )
    .list()


and

Code:
sess.createCriteria(Cat.class)
    .add( Property.forName("id").eq( businessId )
    .list();


The sql that gets generated looks like,

Code:
select ... from SOMETABLE where ID = ?


Is "id" a reserved keyword within queries that can only be used to refer to the <id /> element?

If so are there any workarounds that will cause the following sql be generated instead?

Code:
select ... from SOMETABLE where BUSINESSID = ?


Obviously renaming the property in my class would be one but i'm exploring other possibilities.

Hibernate version:3.1.3

Database: Oracle9i


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

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.