• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Hibernate JPA and orphan deletion  RSS feed

Posts: 19731
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is more or less a Public Service Announcement. I'd report it directly to JBoss/Hibernate but their captcha system is apparently so dependent on one's having the right color vision and monitor characteristics that only spammers can get through it. I can't, so I can't re-activate my old account.

I have the questionable good fortune to be responsible for a system that commits the twin offences of having composite keys AND components of said keys are fixed-length character fields. Very often it bites me.

In this particular case, I think I'm encountering a bug in Hibernate JPA Version 3.6.4. I have a simple parent object associated bidirectionally one-to-many with a set of child objects. The relationship cascades all JPA operations, has orphanRemoval set "true" and just for good measure I attached the deprecated Hibernate-specific @Cascade orphan removal annotation.

When the parent object has children removed from its collection while detached and then a Spring transactional service method is invoked to merge the results back to the database, the operation appears to succeed. Unfortunately, appearances are deceiving. The returned merged object's child collection correctly reflects the removals, but the database does not.

Trying to cache the new/old states of the collection and manually update it can be a little tricky. Here's how I finally worked around the issue:

Anyone here who has a working Hibernate bug-reporting account, please feel free to pass this on. For the rest of us, at least I figure Google can spread the word.
Author and ninkuma
Posts: 66806
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[OFF TOPIC] Heh. Yeah, I recently gave up on joining a technical forum after failing five attempts to get through their ridiculous captcha system.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!