[hibernate-dev] SQL union is not working in SQL query for property attribute "formula" in hibernate mapping
Vadim Gindin
vgindin at gmail.com
Thu Oct 11 07:03:04 EDT 2007
Hello, hibernate-dev!
I've found following problem. I need, that my persistent entity Reference
would have calculated field "title". It is a title of object, that my
Reference entity refers to. My Reference entity also would have identifier
of this object. This object can be an entity of classes in the different
classes hierarhies. I want to calculate title field of Reference as object
title. So, I'm writing this mapping:
<class name="Reference" ..>
<property name="objectId" ../>
<property name="title" formula="(select obj1.title from Table1 obj1 where
obj1.Id=objectId
union
select obj2.title from Table2 obj2 where
obj2.Id=objectId)"/>
</class>
I know, that this query in my case will return only one value.
So, When hibernate is trying to load my Reference entity, it constructs
wrong SQL query (something like this):
select
...,
objectId,
(select obj1.title from Table1 obj1 where obj1.Id=objectId
reference0_.union
select obj2.title from Table2 obj2 where obj2.Id=objectId)
from ReferenceTable reference0_
...
I think it is a bug. Could anybody comment my situation?
P.S. My execution environment: Hibernate-Version: 3.2.5.ga
Sincerely yours, Vadim Gindin
mailto: vgindin at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20071011/0a4c0805/attachment.html
More information about the hibernate-dev
mailing list