-->
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.  [ 3 posts ] 
Author Message
 Post subject: Attributte inverse, what is it for?
PostPosted: Thu Sep 04, 2008 7:36 am 
Beginner
Beginner

Joined: Tue Aug 26, 2008 4:24 pm
Posts: 29
What is the inverse atributte for, I have read about it but I dont get to understand what this is for?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 05, 2008 11:57 am 
Newbie

Joined: Thu Dec 13, 2007 10:49 am
Posts: 5
Inverse is the opposite of the Many-to-one association from the object. This prevents Hibernate from sending multiple SQL updates for one change. So if you add an item B to Object As collection of Bs and save it won't make changes you must set Bs parent to A to get it to persist.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 09, 2008 7:44 pm 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
You'll also see inverse rearing its head in many-to-many relationships as well:

Code:
public class LeftManyStudent {   
  @ManyToMany
  @JoinTable(name = "join_table", 
    joinColumns = { @JoinColumn(name = "lmstudent_id")},
      inverseJoinColumns={@JoinColumn(name="rmcourse_id")})
  public List<RightManyCourse> getCourses(){return courses;}
}


***
Image
***

Code:
public class RightManyCourse {
@ManyToMany
@JoinTable(name = "join_table",
joinColumns={@JoinColumn(name="rmcourse_id")},
inverseJoinColumns={@JoinColumn(name="lmstudent_id")})
public List<LeftManyStudent> getStudents(){return students;}
}


Mapping many-to-many relationships with Hibernate and JPA Annotations Tutorial

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.