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 ... ?
|