-->
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: Symmetric relationship.
PostPosted: Thu Feb 22, 2007 8:02 am 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
Hi,
I have a M:M symmetric relationship, that is a relationship where the role name and POJO type are the same on both sides.
For example, suppose the POJO is Person and the role is family, in code this would look like this:

@Entity
public class Person {
private List <Person> family;
@ManyToMany(mappedBy="family")
public List <Person> getFamily(){
return family;
}

public void setFamily(List <Person> family){
this.family
}
}

However upon start up this will yield the exception:

javax.persistence.PersistenceException: org.hibernate.AnnotationException: Illegal use of mappedBy on both sides of the relationship: Person.family.

Does hibernate support this type of relationship?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 7:13 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
your mapping is illegal, on a bidirectional realtionship there should be really 2 associations.
In your case, it's really a unidirectional relationship. a person has a list of family member

_________________
Emmanuel


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.