Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » cascade-remove bug with UOW
cascade-remove bug with UOW [message #1069862] Tue, 16 July 2013 19:03 Go to next message
Roger Spall is currently offline Roger SpallFriend
Messages: 17
Registered: January 2013
Junior Member
I know this a 'strange scenario' but due to an ongoing migration, I am using Eclipselink JPA (V2.5) but obtaining a UnitOfWork from the EntityManager using the implementation classes. I then delete an object using the uow:

((org.eclipse.persistence.jpa.JpaEntityManager) entityManager.getDelegate()).getUnitOfWork();

uow.deleteObject(o)


The Object model is mapped using JPA XML mapping files, and I know the correct implementation is:

entityManager.remove(o)


And I am 'lowly migrating a large code base to follow this design.

However, the two approaches give very different results! The XML mapping files state <cascade-all> and / or <cascade-remove> for all relationships. However, when using the uow to delete an object the removes are not cascaded, but when using the entityManager they are - orphan deletion still functions the same in both scenarios.

I don't know if this is a bug, because I don't know if the uow approach is actually supported. My goal is to convert all of the code base to use entityManagers, and the difference in behavior is actually working in my favour - because the existing (Native Eclipse legacy code) code behaves exactly the same as it did before regardless of whether <cascade-remove> is set or not, and we only need to consider remove semantics as the querying / manager bean code for each POJO is converted to proper JPA syntax
Re: cascade-remove bug with UOW [message #1069873 is a reply to message #1069862] Tue, 16 July 2013 19:31 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1389
Registered: July 2009
Senior Member
It is not a bug because the JPA contract forces a different cascade setting to be used than EclipseLink native api. JPA allowed setting mappings to cascade the delete using the CascadeType.Remove option, while EclipseLink native methods only delete objects referenced through privately owned relationships. So the native methods are left untouched, and new API with different contracts were added to support JPA and the new cascade type. Both are supported, but have the same functionality as JPA is using on the UnitOfWork, you will need to use the internal performRemove method.
Re: cascade-remove bug with UOW [message #1069880 is a reply to message #1069873] Tue, 16 July 2013 19:42 Go to previous message
Roger Spall is currently offline Roger SpallFriend
Messages: 17
Registered: January 2013
Junior Member
Chris...

Thanks, now it makes sense.

Like I said, I like they way it currently behaves, and it means I don't have to change any of my xml mappings cascade settings until I migrate the individual manager beans that are doing the deletions.
Previous Topic:Understanding 1-many deletion cascading
Next Topic:Nested Embeddable bug?
Goto Forum:
  


Current Time: Thu Apr 25 10:55:17 GMT 2024

Powered by FUDForum. Page generated in 0.11387 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top