-->
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.  [ 1 post ] 
Author Message
 Post subject: XML mapping for unidirectional many-to-many with join table
PostPosted: Wed Oct 07, 2009 1:32 pm 
Newbie

Joined: Wed Oct 07, 2009 1:13 pm
Posts: 1
I'm trying to port our current Hibernate/JPA annotations to Hibernate XML mappings and I've currently gotten stuck on the following relationship:

@ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER, targetEntity = Classifier.class)
@IndexColumn(name = "list_index")
@JoinTable(name = "product_classifiers",
joinColumns = { @JoinColumn(name = "product_id") },
inverseJoinColumns = @JoinColumn(name = "classifier_id"))
public List<Classifier> getClassifiers() { ...

These annotations will persist each Classifier's data and the data for the join table product_classifiers.
However I have been unable to come up with the correct XML mapping for the above. I've tried the following but the data only cascades to the join table and not to Classifier's table:

<class name="Product" table="classifiers">
...
<list name="classifiers" table="product_classifiers" lazy="false"
cascade="persist, merge, refresh">
<key column="product_id" not-null="true" />
<list-index column="list_index" />
<many-to-many class="Classifier" column="classifier_id" lazy="false"/>
</list>
...
</class>
...
<class name="Classifier" table="classifiers">
<id name="id" column="id"/>
<property name="typeId" column="typeId" />
<property name="description" column="description" />
</class>

Any help will be greatly appreciated. -- thx


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

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.