-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: READ_ONLY entity throws because not MANAGED with 3.3.1.GA
PostPosted: Thu Sep 18, 2008 3:40 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
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).

_________________
Carlo
-----------------------------------------------------------
please don't forget to rate if this post helped you


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 18, 2008 4:43 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
I just had another look on my class and saw, that I put the annotation
Code:
@org.hibernate.annotations.Entity(mutable=false)

on the entity which was complained as of State.READ_ONLY.

Now I commented this annotation out, and after restart of the app, I retried and noticed to my BIG surprise, that the error is not there anymore.

Okay, can anyone explain what's the effect of this annotation? Until now, I thought it was just a hint to Hibernate to get some performance hints.

BTW: I also have this annotation on my basic data entity
Code:
@org.hibernate.annotations.Cache(usage = org.hibernate.annotations.CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)

_________________
Carlo
-----------------------------------------------------------
please don't forget to rate if this post helped you


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.