0 Replies Latest reply on Dec 30, 2006 8:21 AM by Christoph Wulf

    list's of composite-element's of Hibernate with Java Persist

    Christoph Wulf Newbie

      Using Hibernate 3 i could define composite-elements like @Embeddable with Java Persistence.
      But Hibernate also allows collections of those composite-element's.

      <class name="entity.Company">
      ...
       <list name="company_addresses">
       <key column="id"/>
       <list-index column="no"/>
       <composite-element class="entity.Address">
       <property name="street"/>
       ...
       </composite-element>
       </list>
      ...
      </class>
      
      <class name="entity.Freelancer">
      ...
       <list name="freelancer_addresses">
       <key column="id"/>
       <list-index column="no"/>
       <composite-element class="entity.Address">
       <property name="street"/>
       ...
       </composite-element>
       </list>
      ...
      </class>
      


      That way i could use an entity like Address in multiple tables linked with several other entities without unnecessary inheritance like CompanyAddress extends Address and FreelancerAddress extends Address or even a kind of polymorphism like Company extends Addressable and Freelancer extends Addressable...

      Is it possible to design such a mapping with EJB 3 annotations?