-->
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: Many-to-many bi-directional association question
PostPosted: Mon Nov 02, 2009 6:37 pm 
Newbie

Joined: Sat Oct 31, 2009 4:20 pm
Posts: 1
Hi all,

I'll preface this with the fact that I'm new to Hibernate, but alas, I have been unable to find the answer to solve my problem while searching the docs, forums, and plenty of results returned by Google for the past couple days.

Here's the general class structure idea (with the fluff removed):

Code:
@Entity
@Table(name = "composite_item")
public class CompositeItem extends DomainModelObject {
   @CollectionOfElements
   @JoinTable(name = "composite_item_has_part", joinColumns = @JoinColumn(name = "parent_id"))
   @MapKeyManyToMany(joinColumns = @JoinColumn(name = "child_id"))
   @Column(name = "quantity")
   private Map<CompositeItem, Double> parts;

   @ManyToMany(mappedBy="parts")
   private List<CompositeItem> parents;
}


This code worked just fine up to the point where I added the "parents" field to the class. At that point, I struggled with having the field properly mapped to the database. I've tried a bunch of different annotations, but none have been successful.

The basic idea is that I'd like to get the "parts" and "parents" fields mapped using one table to map the associations along with the quantity in the "parts" map. Having the bidirectional association is important for the parts of the current system's domain logic to function correctly.


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.