-->
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.  [ 2 posts ] 
Author Message
 Post subject: Deleting only non referenced ...
PostPosted: Tue Dec 23, 2008 10:32 pm 
Newbie

Joined: Tue Dec 23, 2008 10:15 pm
Posts: 3
Hibernate version: last version
Name and version of the database you are using: hsql

How to do this ...

I have Movie and Actor entity, and many to many relation, that is, Movie has list of actors, and actor has list of movies.

When I delete (EntityManager.delete(someMovie)) a movie, I want it to delete also all actors from this movie except those that act in some other movie.

Example:

We have two movies in database, Movie1 and Movie2.
Movie1 has Actor1, Actor2, Actor4.
Movie2 has Actor2, Actor6, Actor7.

When call em.delete(movie2), it should delete Actor6 and Actor7 but not Actor2 because it's referenced by Movie1.

How to do this ? Is it possible using just jpa/hibernate/cascade or I need to write some delete ... from Actors where ... ?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 26, 2008 9:55 am 
Newbie

Joined: Tue Dec 23, 2008 10:15 pm
Posts: 3
Can DELETE_ORPHAN by used with manyToMany relation ?


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