Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 333473

Summary: [Hibernate] Removing object from cross resource containment together with its resource fails
Product: [Modeling] EMF Reporter: Michal Tkacz <Michal.Tkacz>
Component: cdo.coreAssignee: Martin Taal <mtaal>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3 CC: stepper
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 398057    
Attachments:
Description Flags
Test class illustrating the problem
none
Test v2 none

Description Michal Tkacz CLA 2011-01-04 09:19:47 EST
Build Identifier: 

Suppose you have a cross resource containment reference and you want to remove an object from it, together with its resource (it's the only object in its resource).

I tried this sequence:

1. Remove object from reference
2. Remove object's resource using Resource.delete()
3. Commit

For me it fails with

org.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)

After some debugging I decided to add one extra step:

1. Remove object from reference
2. Remove object from its resource << EXTRA STEP
3. Remove object's resource using Resource.delete()
4. Commit

Now it fails with

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

I do not have teneo.mapping.cascade_policy_on_containment set in my cdo-server.xml (my understanding is that it is set to ALL by default).
I'm using the latest 4.0 milestone of CDO.


Reproducible: Always

Steps to Reproduce:
Use attached test class together with code from org.eclipse.emf.cdo.examples.hibernate.client bundle. Note that you may need to run each test method on a fresh database, otherwise they will fail with the same (first) exception.
Comment 1 Michal Tkacz CLA 2011-01-04 09:21:16 EST
Created attachment 186003 [details]
Test class illustrating the problem
Comment 2 Eike Stepper CLA 2011-01-05 12:15:44 EST
Created attachment 186104 [details]
Test v2

This patch works with our test bed. The tests pass, though...
Comment 3 Eike Stepper CLA 2011-01-05 12:20:20 EST
Note, currently org.eclipse.emf.teneo.annotations needs to be recompiled because it was compiled for Java 6.0!
Comment 4 Eike Stepper CLA 2011-01-05 12:22:44 EST
One more note: bothe tests are passing in both, our normal test suite and the Hibernate test suite.
Comment 5 Michal Tkacz CLA 2011-01-05 15:02:15 EST
Eike, I'll check it again and look for possible differences between your environment and mine. If the tests pass for you, then I must be doing something wrong (a probably stupid ;) Can you point me to any resources that desribe configuration of your testbed?
Comment 6 Eike Stepper CLA 2011-01-06 03:26:02 EST
We don't have descriptions of the test process. If you follow http://wiki.eclipse.org/CDO_Source_Installation then you should find some launch configs in your run menu/dialog. Try "CDO AllTests (Hibernate)"...
Comment 7 Eike Stepper CLA 2012-06-05 07:28:46 EDT
Moving all open bug reports to 4.1 because the release is very near and it's hghly unlikely that there will be spare time to address 4.0 problems.

Please make sure that your patches can be applied against the master branch and that your problem is not already fixed there!!!
Comment 8 Eike Stepper CLA 2012-08-14 22:52:48 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 9 Martin Taal CLA 2012-11-24 09:57:27 EST
Thanks for the testcase, I added it to the hibernate test suite.

The testcase passes for the hibernate store. I recently made several changes to the hibernate store, including a better synchronization of hibernate optimistic locking/versioning with the CDO versioning mechanism.

I guess these changes solve the issue. 

Can you retry with a new 4.2 build (will be available later this week)?

Please re-open the issue if it still occurs.

gr. Martin