-->
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: unidirectional many2many relationship with own primary key
PostPosted: Tue Feb 03, 2009 9:06 am 
Newbie

Joined: Wed Dec 10, 2008 5:53 am
Posts: 2
hallo alltogether,

until now I have found how to map a many2many-relationship between to tabels "s" and "d" with the third table "map". Normaly you will use the tweo foreign key as tablekey for map. But in the legacy database I work with the map table also has a own primary key. How to map this without a own Java entity?

@Entity
@Table(name="s")
public class Src {
@Id
@Column(name="s_id")
int getId() { ... }

@ManyToMany
@JoinTable(name="map",
joinColumns={@JoinColumn(name="s_key")},
inverseJoinColumns={@JoinColumn(name="d_key")})
Collection<Dst> getChildren() { ... }
}



@Entity
@Table(name="d")
public class Dst {
@Id
@Column(name="d_id")
int getId() { ... }
}

The relationship has no additional information and must be mapped only at one side of the relationship.

The database structure couldn't be changed.

thakyou for any hint
Sunshine08


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.