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