Hibernate version:
3.2.5.ga
Mapping documents:
Code:
<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>
Name and version of the database:PostgreSQL 8.1
Generated SQL:Code:
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_
...
Hello. Sorry for my english.
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 (see "Mapping documents").
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 (see "Generated SQL").
I think it is a bug. Could anybody comment my situation?
Sincerely, Vadim Gindin