-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Reverse relation of a <any> association
PostPosted: Fri Jun 24, 2005 9:03 am 
Newbie

Joined: Fri Jun 24, 2005 4:55 am
Posts: 1
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 24, 2005 10:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, it is possible with a bog standard one-to-many mapping.

But if I were you, I would very seriously consider using HB3 union-subclass for this stuff.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.