Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Are you modeling a bi-directional referential relationship or an inheritance hierarchy?</p> <p>If the object model is an inheritance hierarchy, then the relationship should not need to be bi-directional, and the solution is to obtain the sub-class instance from the sub-class DAO. This removes the need to navigate from the base class to the sub-class in the base class DAO. This is what I was attempting to explain in my original answer (below).</p> <p>If the object model is a bi-directional relationship, then you need to set inverse="true" on the set or bag at the "one" end of the relationship - in this case BasicEntity.</p> <p>Hibernate 3 allows the use of indexed collections at the "one" end of the relationship, but the Hibernate 2 functionality with set or bag should be enough to test the theory.</p> <p>This link might help: <a href="https://www.hibernate.org/193.html" rel="nofollow noreferrer" title="Bidirectional one-to-many with an indexed collection">https://www.hibernate.org/193.html</a> Also: Hibernate Quickly pp142 - 145; Hibernate in Action pp108 - 111.</p> <hr> <p>If I understand the problem correctly, you want to build a VersionedEntity from two tables, using data obtained like this:</p> <pre><code>select * from basic_entity be, versioned_entity ve where ve.id = be.id and ve.id = &lt;id&gt; and ve.active_version=&lt;version&gt; </code></pre> <p>Given your constraints on not calling one DAO from another, I wonder whether the chosen method correctly expresses the intent: </p> <pre><code>public my.VersionedEntity my.BasicEntityDAO.getActiveVersionedEntity(); </code></pre> <p>Could you implement a method like this instead:</p> <pre><code>public my.VersionedEntity my.VersionedEntityDAO.getActive(); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload