-->
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.  [ 3 posts ] 
Author Message
 Post subject: Trouble with read-only caching
PostPosted: Mon Feb 11, 2008 7:16 pm 
Newbie

Joined: Mon Feb 11, 2008 6:38 pm
Posts: 2
Hi,

I have my lookup data (in this case EventType) set up as a read-only cache.

Everything works fine except...


I have another object, Event, that contains an EventType.

If I make a new Event, find and set the proper EventType, and then do a saveOrUpdate on it, I get the following error:
Code:
java.lang.UnsupportedOperationException: Can't write to a readonly object    at org.hibernate.cache.ReadOnlyCache.lock(ReadOnlyCache.java:43)    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:85)


I have cascade="none" set on the .hbm.xml, so I would think that it would not try to persist the EventType object on saveOrUpdate, but it obviously is.

I looked in the forums and was not able to find a way to fix this.

Event.hbm.xml:


Code:
<hibernate-mapping package="com.evite.event.model">
   <class name="Event" table="EVENTS">
      <id name="id" column="EVENTID" type="string">
         <generator class="assigned"/>
      </id>
      <property name="title" column="TITLE" type="string" />
...
      <many-to-one name="eventType" lazy="proxy" class="com.evite.event.model.EventType" cascade="none" column="EVENT_TYPE" />
   </class>




EventType.hbm.xml:

Code:
   <class name="EventType" table="EVENT_TYPES">
      <cache usage="read-only"/>
      <id name="eventType" column="EVENT_TYPE" type="string">
         <generator class="assigned"/>
      </id>
      <property name="displayName" column="DISPNAME" type="string" />
   </class>


I am just hoping that there is a way to prevent hibernate from doing the update to EventType.
Sorry if I missed relevant posts on the subject.

Thank you,
Jeff


Top
 Profile  
 
 Post subject: Re: Trouble with read-only caching
PostPosted: Mon Feb 11, 2008 8:22 pm 
Expert
Expert

Joined: Wed Apr 11, 2007 11:39 am
Posts: 735
Location: Montreal, QC
Umm, what if on EventType class tag you add mutable="false". That might do the trick.


Farzad-


Top
 Profile  
 
 Post subject: that did the trick
PostPosted: Mon Feb 11, 2008 11:02 pm 
Newbie

Joined: Mon Feb 11, 2008 6:38 pm
Posts: 2
that worked, hibernate is no longer trying to update.
can't believe i missed that attribute.

thanks!!!
Jeff


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