-->
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.  [ 4 posts ] 
Author Message
 Post subject: SecondLevel Cache : Can't write to a read only object
PostPosted: Thu Sep 03, 2009 12:01 pm 
Newbie

Joined: Wed Sep 02, 2009 7:34 pm
Posts: 2
Hello,

We are using EHCACHE as the second level caching mechanism in our Hibernate project. As part of EHCACHE configuration I want to cache certain associations.

Thus in a hbm file I have added

<cache usage="read-only" />

at the class level and also at the association level.

Code:
   <set
         name="Events"
         inverse="true"
         cascade="none"
         lazy="false">
         <cache usage="read-only" />
         <key column="EVENT_DETAIL_TYPE_ID"/>         
         <one-to-many class="com.mycomp.proj.common.domain.message.MessageDetailType"/>
      </set>   



However due to the addition of

<cache usage="read-only" />

at the association it gives me this error :

Can't write to a readonly object
java.lang.UnsupportedOperationException: Can't write to a readonly object


What is the reason for this ? I can make it work if I make it <cache usage="read-write" />. However I want to keep it read-only.

In the hbm file at the class level, I have stated mutable="false". How do I do that for the association ? Adding mutable as an attribute of 'set' does not seem to work (although it should have).Anyways, although I strongly feel that it is due to mutable issue, it maybe due to somthing else. Any ideas / suggestions ?

Thanks and regards,
Milan


Top
 Profile  
 
 Post subject: Re: SecondLevel Cache : Can't write to a read only object
PostPosted: Thu Sep 03, 2009 11:54 pm 
Newbie

Joined: Wed Oct 01, 2008 2:27 pm
Posts: 18
doshi_milan wrote:
Can't write to a readonly object
java.lang.UnsupportedOperationException: Can't write to a readonly object
[/i]

What is the reason for this ?


Looks like you are trying to modify the object (or the set)?


Top
 Profile  
 
 Post subject: Re: SecondLevel Cache : Can't write to a read only object
PostPosted: Fri Sep 04, 2009 12:37 am 
Newbie

Joined: Wed Sep 02, 2009 7:34 pm
Posts: 2
Good Point. I should have mentioned it in my original post that I am NOT updating the object(the association).

Thanks,
Milan


Top
 Profile  
 
 Post subject: Re: SecondLevel Cache : Can't write to a read only object
PostPosted: Fri Sep 04, 2009 1:57 am 
Newbie

Joined: Wed Oct 01, 2008 2:27 pm
Posts: 18
doshi_milan wrote:
Good Point. I should have mentioned it in my original post that I am NOT updating the object(the association).


Looks like Hibernate thinks the object was updated anyway? May be worth disabling the cache (or setting it to read-write) and looking at the logging output...

Is the exception thrown when you close the session? Assuming you are not also updating objects in the same session, you could prevent Hibernate from flushing: session.setFlushMode(FlushMode.NEVER).


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.