Hello, hibernate-dev!<br><br>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:
<br><br><span style="font-family: courier new,monospace;"><class name="Reference" ..></span><br style="font-family: courier new,monospace;"> <span style="font-family: courier new,monospace;"><property name="objectId" ../>
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> <property name="title" formula="(</span><span style="font-family: courier new,monospace;">select
obj1.title from Table1 obj1 where obj1.Id=objectId<br>
<span style="font-weight: bold;">union</span><br>
</span><span style="font-family: courier new,monospace;">select obj2.title from Table2 obj2 where obj2.Id=objectId</span><span style="font-family: courier new,monospace;">)"/></span>
<br><span style="font-family: courier new,monospace;"></class><br><br>I know, that this query in my case will return only one value.<br><br>So, When hibernate is trying to load my Reference entity, it constructs wrong SQL query (something like this):
<br><br>select <br></span><span style="font-family: courier new,monospace;"> ...,<br>
</span><span style="font-family: courier new,monospace;"> objectId,<br> (select obj1.title from Table1 obj1 where obj1.Id=objectId<br> </span><span style="font-family: courier new,monospace; color: rgb(204, 0, 0); font-weight: bold;">
reference0_.</span><span style="font-family: courier new,monospace;"><span style="color: rgb(0, 0, 0); font-weight: bold;">union</span><br> select obj2.title from Table2 obj2 where obj2.Id=objectId)</span><br>
<span style="font-family: courier new,monospace;">from ReferenceTable reference0_<br>...<br><br><span style="font-family: arial,sans-serif;">I think it is a bug. Could anybody comment my situation?<br><br>P.S. My execution environment: Hibernate-Version:
<a href="http://3.2.5.ga" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">3.2.5.ga</a><br><br style="font-family: arial,sans-serif;"></span><span style="font-family: arial,sans-serif;">Sincerely yours, Vadim Gindin
</span><br style="font-family: arial,sans-serif;"><span style="font-family: arial,sans-serif;">
mailto: <a href="mailto:vgindin@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">vgindin@gmail.com</a></span><br></span>