-->
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: Bidirectional OneToMany assoc. along with joined-subclass
PostPosted: Wed Apr 10, 2013 6:36 am 
Newbie

Joined: Thu Jun 07, 2012 10:03 am
Posts: 8
Hi,

How to represent a bidirectional One-To-Many association in XML when joined-subclass is used?

My two classes:

Code:
public class A {
    private Long id;
    private Set<B> bs = new HashSet<B>();
}

public class B {
    private Long id;
    private A a;
}


I need a bidirectional OneToMany association between A and B.

My XML mapping:

Code:
<hibernate-mapping>
  <class name="A">
    <id name="id" access="field">
      <column name="aId" />
      <generator class="identity" />
    </id>
    <set name="bs" access="field" table="A_B">
      <key column="aId" />
      <many-to-many column="bId" class="B" unique="true" />
    </set>
  </class>
</hibernate-mapping>

<hibernate-mapping>
  <class name="B">
    <id name="id" access="field">
      <column name="bId" />
      <generator class="identity" />
    </id>   
    <join table="A_B" inverse="true" optional="true">
      <key column="bId" />
      <many-to-one name="a" column="aId" not-null="true" />
    </join>
    <joined-subclass name="...." table="....">
      ....
    </joined-subclass>
  </class>
</hibernate-mapping>


There is an error with the XML syntax, it seems that it's not allowed to use the <join> element with the <joined-subclass> element.

Any idea?

Thanks


Last edited by Miko95 on Thu Apr 18, 2013 10:04 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Representing a bidirectional OneToMany association when join
PostPosted: Thu Apr 18, 2013 10:02 am 
Newbie

Joined: Thu Jun 07, 2012 10:03 am
Posts: 8
?????


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.