-->
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: different cascade behavior with Set and List?
PostPosted: Fri May 09, 2008 1:25 am 
Newbie

Joined: Mon Mar 19, 2007 7:47 pm
Posts: 6
I'm getting a interesting behavior difference between Set and List. When using Set, the cascade delete works great, i.e. the children are deleted first, then the parent.

but... when using a List, the children are not deleted first, resulting in a constraint violation.

anyone else seen this?

using Hibernate 3.2.6GA, and Annotations 3.3.0GA. Not using Entity Manager.

... using set

@OneToMany(mappedBy="parent",
cascade=CascadeType.REMOVE)
@OrderBy("displayorder")
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private List<Child> children = new ArrayList<Child>();

... using list

@OneToMany(mappedBy="parent",
cascade=CascadeType.REMOVE)
@org.hibernate.annotations.Fetch(org.hibernate.annotations.FetchMode.SUBSELECT)
private Set<Child> children = new HashSet<Child>();


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.