-->
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: Bug with JPA Annotations example from JP w/ Hib (p. 269)?
PostPosted: Sat Jul 11, 2009 12:31 pm 
Newbie

Joined: Sat Jul 11, 2009 12:14 pm
Posts: 1
In Java Persistence with Hibernate (p. 269), the example
Code:
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },
              mappedBy = "item")
private Set<Bid> bids = new HashSet<Bid>();


implies that session.save(item) will save all associated bid instances. That's not what I'm finding.

I have a bi-directional one-to-many, many-to-one relation, and saving the one instance doesn't save the associated many instances. If, however, I change the annotations (just the annotations, none of the actual code) to use org.Hibernate CascadeType class :

Code:
@OneToMany(mappedBy = "item")
@Cascade(value = CascadeType.SAVE_UPDATE)
private Set<Bid> bids = ...;


everything gets saved correctly.

Is this expected behavior, because it's sure not what I expected from the text?


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.