Yesterday I downloaded Hibernate 3.3.1.GA and tried it with our application (in our production version we are using 3.2.6.GA).
I soon ran into an exception which is not thrown using version 3.2.6. We have some basic read only data in our application, i.e. status entities. These entities do not change and therefore are held in cache marked as READ_ONLY. Now there is a curious situation with Hibernate 3.3.1: on some business entities which hold a relation to one of those read only entities, everything works as in version 3.2.6; on other entities we now get an exception when we call the JPA merge() operation to update or insert the object. The method
Code:
DefaultMergeEventListener.onMerge(MergeEvent event)
throws an exception:
Quote:
Merged entity does not have status set to MANAGED; EntityEntry[org.dpjw.base.domain.Feature#3](READ_ONLY) status=READ_ONLY
Curiously: the complained entity "Feature" is not directly used by the business object, but only referenced indirectly by it's "child" which itself is used by the business object to be saved.
Can anyone of the Hibernate experts explain why this is done and under what conditions? As I said, we are using the complained Feature object with other business objects, and on their merge()-call the READ_ONLY object has no merge event (I tested it with a break point at onMerge).