-->
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: @ManyToMany
PostPosted: Mon Jul 27, 2009 7:53 pm 
Newbie

Joined: Mon Jul 27, 2009 7:40 pm
Posts: 1
Hi all,

Currently, I have a many to many relationship between two classes Foo and Bar. In Foo.java, I have the following code in Foo.java:

Code:
private Set<Bar> bars;

@ManyToMany(fetch = FetchType.EAGER)
  @JoinTable(
    name = "foos_bars"
    joinColumns = {@JoinColumn(name = "foo_id")},
    inverseJoinColumns = {@JoinColumn(name = "bar_id")}
  )
  public Set<Bar> getBars() {
    return bars;
  }
  public void setBars(Set<Bar> bars) {
    this.bars = bars;
  }


Now, I want to make the following changes:
-add a "weight" column to the foos_bars join table so that each Bar associated in a Foo's Set<Bar> can have a weight value.
-replace Set<Bar> instance variable in Foo.java with Map<Bar, Integer> to represent the weight associated with each Bar.

I'm having trouble coming up with the correct annotations to achieve this. Can anyone point me in the right direction?


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.