-->
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: Question about Hibernate doc
PostPosted: Fri Jun 10, 2011 9:57 am 
Newbie

Joined: Tue Nov 04, 2008 3:07 am
Posts: 9
Here:
Hi all,
Here:
http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/

It is written that:
Quote:
many to one are (almost) always the owner side of a bidirectional relationship


In the Doc sample the many to one is the Soldier entity is that so?
Way Soldier is the owner side of bidirectional relationship?
When you save a Troop object you would like to save its entire Soldier's automatically, so Troop will always be the owner side of the relationship, am I correct?


Code:
2.2.5.3.1.1. Bidirectional
Since many to one are (almost) always the owner side of a bidirectional relationship in the JPA spec, the one to many association is annotated by @OneToMany(mappedBy=...)

@Entity
public class Troop {
    @OneToMany(mappedBy="troop")
    public Set<Soldier> getSoldiers() {
    ...
}

@Entity
public class Soldier {
    @ManyToOne
    @JoinColumn(name="troop_fk")
    public Troop getTroop() {
    ...
}         


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.