Message:
The following issue has been closed.
Resolver: Gavin King
Date: Wed, 13 Aug 2003 4:38 AM
Thanks, I fixed it in 2.1 branch.
---------------------------------------------------------------------
View the issue:
http://opensource.atlassian.com/projects/hibernate/secure/ViewIssue.jspa?key=HB-251
Here is an overview of the issue:
---------------------------------------------------------------------
Key: HB-251
Summary: error query table with "where" attribute in <class> mapping
Type: Bug
Status: Closed
Priority: Major
Resolution: FIXED
Project: Hibernate2
Fix Fors:
2.1 beta 2
Versions:
2.0.2
Assignee: Gavin King
Reporter: Dominik Roblek
Created: Tue, 12 Aug 2003 6:32 AM
Updated: Wed, 13 Aug 2003 4:38 AM
Description:
I added "where" attribute to <class> mapping of Party class, which has Person and Organization subclasses mapped via <joined-subclass>.
When executing Hibernate scalar query, is table column from "where" condition prefixed with wrong table alias. It is prefixed with Person table alias instead of Party table alias. It causes SQL error.
Here is my hbm.xml:
---
<hibernate-mapping>
<class
name="si.marand.maf.server.jastreb.party.module.entity.PartyEntity"
table="Party"
dynamic-update="false"
dynamic-insert="false"
where="MAF_Deleted=0">
<jcs-cache usage="read-write"/>
<id name="id" column="Party_ID" type="java.lang.Long" unsaved-value="0">
...
</id>
...
<joined-subclass
name="si.marand.maf.server.jastreb.party.module.entity.PersonEntity"
table="Person"
dynamic-update="false"
dynamic-insert="false"
proxy="si.marand.maf.server.jastreb.party.module.entity.PersonEntity">
<key column="Person_ID"/>
...
</joined-subclass>
<joined-subclass
name="si.marand.maf.server.jastreb.party.module.entity.OrganizationEntity"
table="Organization"
dynamic-update="false"
dynamic-insert="false">
<key column="Organization_ID"/>
...
</joined-subclass>
</class>
</hibernate-mapping>
---
Here is wrongly generated query:
---
select
personen0_.Person_ID as x0_0_,
personen0_.First_Name as x1_0_,
personen0_.Last_Name as x2_0_,
personen0__1.Party_Id_Num as x3_0_,
addresse2_.Street_1 as x4_0_,
addresse2_.Street_2 as x5_0_,
addresse2_.Street_3 as x6_0_,
addresse2_.Street_4 as x7_0_
from
Person personen0_
inner join Party personen0__1 on personen0_.Person_ID=personen0__1.Party_ID
inner join Party_Address partyadd1_ on personen0_.Person_ID=partyadd1_.Party_ID
inner join Address addresse2_ on partyadd1_.Address_ID=addresse2_.Address_ID
where
personen0_.MAF_Deleted=0 and
(((personen0__1.MAF_Deleted=0 ))and((addresse2_.Street_1 like ? )or(addresse2_.Street_2 like ? )
or(addresse2_.Street_3 like ? )or(addresse2_.Street_4 like ? )))
---
Condition "MAF_Deleted=0" should be prefixed with "personen0__1" alias instead of "personen0_" alias.
Dominik
---------------------------------------------------------------------
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
|