Hi,
I have two classes EmpA and EmpB that inherit from a Java interface IEmp. Another class Person has a one-to-one association to IEmp.
To do that, EmpA and EmpB are mapped as concrete classes, IEmp is of course not mapped, and I use the <any> tag in the Person mapping file in order to make association from Person object to EmpA or EmpB object (see diagram below).
IEmp <--------------------------- Person
^
|
-----------
| |
EmpA EmpB
I would like to make this association bi-directionnal to allow getting Person objects from EmpA/B objects.
Is it possible ?
Thanks
Hibernate version:
2.1.8
Mapping documents:
EmpA mapping file:
""""""""""""""""""""""
<hibernate-mapping default-cascade="save-update">
<class name="com.lectra.mapgentest.domain.test.onetoone.EmpA" table="EMP_A" lazy="true">
<id
name="id"
type="java.lang.Long">
<generator class="native"/>
</id>
<!--
Here I want to declare a reverse association named "person" from EmpA to Person
-->
</class>
</hibernate-mapping>
Person mapping file:
"""""""""""""""""""""""
<hibernate-mapping default-cascade="save-update">
<class name="com.lectra.mapgentest.domain.test.onetoone.Person" table="PERSON" lazy="true">
<id
name="id"
type="java.lang.Long">
<generator class="native"/>
</id>
<any name="emp" id-type="java.lang.Long">
<column name="emp_type" />
<column name="emp_id"/>
</any>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
N/A
Full stack trace of any exception that occurs:
N/A
Name and version of the database you are using:
Oracle 10g
The generated SQL (show_sql=true):
N/A
Debug level Hibernate log excerpt:
N/A
|