-->
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.  [ 4 posts ] 
Author Message
 Post subject: Update contents of a collection
PostPosted: Mon Sep 19, 2005 8:33 pm 
Newbie

Joined: Sat Apr 30, 2005 7:23 pm
Posts: 4
Ok, I am most assuredly doing something stupid .. but I have read all I could and can't find what.

I am using The Hibernate EJB 3 annotations with the Hibernate sesion management.

I have a relation like the following

class Parent
{
Collection<Child> mChildren = new ArrayList<Child>();

@OneToMany(cascade = CascadeType.ALL, mappedBy="parent")
public Collection<Child> getChildren()
{
...
}
}

class Child
{
private Parent mParent;

@ManyToOne
public Parent getParent()
{
...
}
}


Once create, delete works as expected. The children gets removed from the database.

However, if I keep the parent, and replace the children, the old children are left behind in the database! So that next time the Object gets loaded, it has all the old and new children ...

Now, this is pretty basic stuff .. so please can someone point me in the right direction?

Thanks.

Steve


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 5:26 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
@org.hibernate.annotations.Cascade({org.hibernate.annotations.CascadeType.DELETE_ORPHAN})

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 10:40 am 
Newbie

Joined: Sat Apr 30, 2005 7:23 pm
Posts: 4
Humm ... ok I guess that solves my problem for now ... but I was relly hoping for a solution that would not use a hibernate extension ....

Isn't there a way to get this to work using only the standard annotations?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 21, 2005 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
No, this feature hasn't been standardized

_________________
Emmanuel


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