Message:
The following issue has been closed.
Resolver: Gavin King
Date: Tue, 26 Aug 2003 1:25 PM
As per Hibernate documentation this is correct and expected.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-289
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-289
Summary: using alias with id that isn't primary key causes where clauses to swap out to primary key name
Type: Bug
Status: Closed
Priority: Major
Resolution: REJECTED
Project: Hibernate2
Components:
core
Versions:
2.1 beta 1
Assignee:
Reporter: Mark Proctor
Created: Mon, 25 Aug 2003 6:55 PM
Updated: Tue, 26 Aug 2003 1:25 PM
Environment: Windows XP, Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
Description:
if I have the following mapping file(note how I use "id" as name for a normal column, and guid as the primary key):
<hibernate-mapping>
<class name="Revision" table="Revision">
<id name="guid" type="java.lang.String" column="guid">
<generator class="uuid.hex"/>
</id>
<property name="id" column="id" type="java.lang.String"/>
<property name="version" column="version" type="long"/>
<property name="fromDate" column="fromDate" type="java.util.Date"/>
<property name="toDate" column="toDate" type="java.util.Date"/>
</class>
</hibernate-mapping>
and I try the following query:
from com.domain.package.Revision as rev where rev.id=? and rev.toDate is null
I get id swapped out to guid, as shown in the SQL below:
select revision0_.guid as guid, revision0_.id as id, revision0_.version as version, revision0_.fromDate as fromDate, revision0_.toDate as toDate from Revision revision0_ where revision0_.guid=? )and(revision0_.toDate is null )
It works correctly when aliases are not used, note how I have to use the table name directly on the where clauses, as you cant use the object name:
from com.domain.package.Revision where Revision.id=? and Revision.toDate is null
this gives the sql:
select revision0_.guid as guid, revision0_.id as id, revision0_.version as version, revision0_.fromDate as fromDate, revision0_.toDate as toDate from Revision revision0_ where (Revision.id=? )and(Revision.toDate is null )
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
|