Hello, hibernate-dev!<br><br>I&#39;ve found following problem. I need, that my persistent entity Reference would have calculated field &quot;title&quot;. 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&#39;m writing this mapping:
<br><br><span style="font-family: courier new,monospace;">&lt;class name=&quot;Reference&quot; ..&gt;</span><br style="font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; <span style="font-family: courier new,monospace;">&lt;property name=&quot;objectId&quot; ../&gt;
</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">&nbsp; &lt;property name=&quot;title&quot; formula=&quot;(</span><span style="font-family: courier new,monospace;">select 
obj1.title from Table1 obj1 where obj1.Id=objectId<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-weight: bold;">union</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </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;">)&quot;/&gt;</span>

<br><span style="font-family: courier new,monospace;">&lt;/class&gt;<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;">&nbsp; ...,<br>
</span><span style="font-family: courier new,monospace;">&nbsp; objectId,<br>&nbsp;&nbsp; (select obj1.title from Table1 obj1 where obj1.Id=objectId<br>&nbsp; &nbsp; &nbsp;&nbsp;&nbsp; </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>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; 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>