-->
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: help with OneToMany save!
PostPosted: Mon Sep 19, 2005 9:43 pm 
Newbie

Joined: Mon Nov 08, 2004 11:17 am
Posts: 3
Location: Buenos Aires, Argentina
Hi,
I'm working with hibernate-annotations-3.1beta5 with mySQL and I have this problem:

The class Player has an association (OneToMany) to field "stars" as follows:

Code:
@Entity(access = AccessType.FIELD)
public class Player {
        ...
   @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "owner")
   private Collection<Star> stars;
}

The Star class has an association as follows:

Code:
@Entity(access = AccessType.FIELD)
public class Player {
        ...
   @ManyToOne(cascade = CascadeType.ALL)
   @JoinColumn(name = "owner")
   private Player owner;
}


Also, the class Player has a method who adds a star to the collection (and initializates if null), like this:

Code:
   
public void addStar(Star star) {
        star.setOwner(this);
   getStars().add(star);
}


Later, when is needed, I call session.save(player)... it inserts Player, but no updates the "star" object in "stars" collection...

Does anybody can help me?

Thanks, and sorry for my awful english :)


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.