Advertisement

04.21.2005 at 06:18AM PDT, ID: 21397272
[x]
Attachment Details

Hibernate delete cascade

Asked by stephan_zehnder in Java Programming Language, J2EE, J2EE Frameworks

Tags: hibernate, delete, cascade

I have a simple one-to-many mapping which looks the following using xdoclet in my class PersistentReportDefinition:

@hibernate.set inverse="true" table="time_span" lazy="false" name="timeSpans" cascade="all-delete-orphan"
@hibernate.collection-key column="report_def_id"
@hibernate.collection-one-to-many class="com.nexusatwork.nrs.collectable.persistence.mapped.PersistentTimeSpan"

I first create a ReportDefinition which has three such PersistentTimeSpanS in a Set. This works very well, they are saved cascading.

Later on I want to delete a time span from the set. But I do not have the original instance of PersistentReportDefinition, so I build up a new one but with only 2 PersistentTimeSpanS in the set. The primary keys are set, so hibernate knows it has to update and not to insert.

The problem is, that it does not delete the PersistentTimeSpan which is not in the Set. Does Hibernate only realize it has to remove when I actually call remove on the Set, or whats the problem? Start Free Trial
[+][-]04.21.2005 at 09:16AM PDT, ID: 13835459

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.21.2005 at 11:29AM PDT, ID: 13836735

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.24.2005 at 11:44PM PDT, ID: 13856479

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.24.2005 at 11:56PM PDT, ID: 13856508

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.25.2005 at 12:07AM PDT, ID: 13856532

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2005 at 12:10AM PDT, ID: 13856540

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2005 at 12:18AM PDT, ID: 13856566

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Java Programming Language, J2EE, J2EE Frameworks
Tags: hibernate, delete, cascade
Sign Up Now!
Solution Provided By: aozarov
Participating Experts: 2
Solution Grade: A
 
 
[+][-]04.25.2005 at 12:22AM PDT, ID: 13856573

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.25.2005 at 06:31AM PDT, ID: 13858155

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32