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.
Customer surveys are for companies who didn't pay proper attention to begin with.