-->
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.  [ 14 posts ] 
Author Message
 Post subject: Read only cache for mutable class
PostPosted: Fri Jan 20, 2006 2:22 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 12:26 pm
Posts: 21
The issue is
I have some classes that are declared immutable in their mappings. Some of them contain sets. If an immutable class contains a mapped set, I get a "WARN : read-only cache configured for mutable class" error. If I add a mutable="false" attribute to the set element in the mapping, I get a SAXParseException saying "attribute mutable is required for element set", which is confusing because I only get the error when the attribute is there. Is there any way that I can get rid of these warnings? They're annoying. Is this, maybe, a bug?

See below for full warning text

Hibernate version: 3.1.1

Mapping documents:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
  <class name="com.idex.processtracking.bean.StepDetail" table="StepDetails"
      mutable="false">
    <cache usage="read-only" />
    <id column="id" name="id" type="integer">
      <generator class="increment"/>
    </id>
    <many-to-one name="step" class="com.idex.processtracking.bean.ProcessStep"
        column="stepID" cascade="all" unique="false" not-null="true" />
    <property name="name" column="name" type="string" not-null="true" />
    <property name="type" column="type" type="string" not-null="true" />
    <set name="optionValuesSet" inverse="true" cascade="none">
      <cache usage="read-only" />
      <key column="stepDetailID" />
      <one-to-many class="com.idex.processtracking.bean.StepDetailOptionValue"
          />
    </set>
  </class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

Code:
WARN : read-only cache configured for mutable class: com.idex.processtracking.bean.StepDetail.optionValuesSet <org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:43)> [2006-01-20 11:52:12,243]


Top
 Profile  
 
 Post subject: More detail
PostPosted: Fri Jan 20, 2006 2:29 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 12:26 pm
Posts: 21
Here's the exception generated if mutable="false" is added to the set element.

Code:
WARN : Could not perform validation checks for component as the class com.idex.processtracking.bean.NextStep was not found <org.hibernate.cfg.HbmBinder.bindCompositeId(HbmBinder.java:422)> [2006-01-20 11:51:15,827]
ERROR: Error parsing XML: XML InputStream(14) Attribute "mutable" must be declared for element type "set". <org.hibernate.util.XMLHelper$ErrorLogger.error(XMLHelper.java:59)> [2006-01-20 11:51:15,918]
ERROR: Building SessionFactory failed. <com.idex.hibernate.HibernateUtility.<clinit>(HibernateUtility.java:44)> [2006-01-20 11:51:15,938]
org.hibernate.MappingException: Error reading resource: com/idex/processtracking/bean/StepDetail.hbm.xml
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:452)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1263)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1235)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1217)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1184)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1112)
   at org.hibernate.cfg.Configuration.configure(Configuration.java:1098)
   at com.idex.hibernate.HibernateUtility.<clinit>(HibernateUtility.java:37)
   at com.idex.processtracking.action.WelcomeAction.execute(WelcomeAction.java:47)
   at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
   at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
   at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
   at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at com.idex.hibernate.CloseSessionFilter.doFilter(CloseSessionFilter.java:32)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Thread.java:595)
Caused by: org.hibernate.MappingException: invalid mapping
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
   at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
   ... 31 more
Caused by: org.xml.sax.SAXParseException: Attribute "mutable" must be declared for element type "set".
   at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
   at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
   at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.dom4j.io.SAXReader.read(SAXReader.java:465)
   at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)
   ... 32 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 25, 2006 11:58 am 
Beginner
Beginner

Joined: Fri Oct 28, 2005 12:26 pm
Posts: 21
Anybody know about mutability in caching?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 4:18 pm 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:10 pm
Posts: 22
Hi,

I have the same problem as described. If I try to use the mutable="false" attribute for a set, I get the exception "Attribute "mutable" must be declared for element type "set"" as the one below. If I remove all the mutable attributes from all the set elements in the mapping for a class, the exception does not occur.

It is really confusing. How does one get mutable="false" for a set to work?

Thanks.

Caused by: org.hibernate.MappingException: invalid mapping
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:399)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:449)
... 87 more
Caused by: org.xml.sax.SAXParseException: Attribute "mutable" must be declared for element type "set".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.addDTDDefaultAttrsAndValidate(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:334)
at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:398)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 5:21 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The exception means that the grammar doesn't allow the mutable attribute on a set. If you have a look at the definition of <map>. <set> or any of the other collection tags, you'll see that mutable isn't given as a valid attribute.

The mutability of a set is defined by the mutability of the class that describes the join table (if there is one), or by the mutability of the class directly in the set (if there is no join table). For the very common case of an unmapped join table (a <set> containing a <many-to-many>), it is always mutable: to make it immutable, you would have to implement it as a many-to-one-to-many, and make the class describing the join table be immutable.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 5:25 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 12:26 pm
Posts: 21
The mutable attribute in the schema for the Set element. Why do I get a warning when it's not there? Also, why is it that only after I add the attribute that Hibernate tells me it's required and throws an exception?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 5:27 pm 
Beginner
Beginner

Joined: Fri Oct 28, 2005 12:26 pm
Posts: 21
Just for clarity, here's the warning again. optionValuesSet is a set in the StepDetail class.

Code:
WARN : read-only cache configured for mutable class: com.idex.processtracking.bean.StepDetail.optionValuesSet <org.hibernate.cache.CacheFactory.createCache(CacheFactory.java:43)> [2006-01-20 11:52:12,243]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 5:37 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
The mutable attribute is not in the schema for Set. The exception is telling you to remove it, not that it is required. Perhaps it's badly worded, but that's what it means. Here is the extract from the DTD for set:
Code:
<!ELEMENT set (
   meta*,
   subselect?,
   cache?,
   synchronize*,
   comment?,
   key,
   (element|one-to-many|many-to-many|composite-element|many-to-any),
   loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,
   filter*
)>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 6:10 pm 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:10 pm
Posts: 22
Actually it looks like "set" should support the "mutable" attribute. See <!ATTLIST set mutable (true|false) "true"> below. The full DTD is available at http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd

Code:
<!ELEMENT set (
   meta*,
   subselect?,
   cache?,
   synchronize*,
   comment?,
   key,
   (element|one-to-many|many-to-many|composite-element|many-to-any),
   loader?,sql-insert?,sql-update?,sql-delete?,sql-delete-all?,
   filter*
)>
   <!ATTLIST set name CDATA #REQUIRED>
   <!ATTLIST set access CDATA #IMPLIED>
   <!ATTLIST set table CDATA #IMPLIED>                                                <!-- default: name -->
   <!ATTLIST set schema CDATA #IMPLIED>                                             <!-- default: none -->
   <!ATTLIST set catalog CDATA #IMPLIED>                                             <!-- default: none -->
   <!ATTLIST set subselect CDATA #IMPLIED>
   <!ATTLIST set lazy (true|false|extra) #IMPLIED>
   <!ATTLIST set sort CDATA "unsorted">                                              <!-- unsorted|natural|"comparator class" -->
   <!ATTLIST set inverse (true|false) "false">
   <!ATTLIST set mutable (true|false) "true">
   <!ATTLIST set cascade CDATA #IMPLIED>
   <!ATTLIST set order-by CDATA #IMPLIED>                                              <!-- default: none -->
   <!ATTLIST set where CDATA #IMPLIED>                                                <!-- default: none -->
   <!ATTLIST set batch-size CDATA #IMPLIED>
   <!ATTLIST set outer-join (true|false|auto) #IMPLIED>
   <!ATTLIST set fetch (join|select|subselect) #IMPLIED>
   <!ATTLIST set persister CDATA #IMPLIED>   
   <!ATTLIST set collection-type CDATA #IMPLIED>                                          
   <!ATTLIST set check CDATA #IMPLIED>                                                <!-- default: none -->
   <!ATTLIST set optimistic-lock (true|false) "true">      <!-- only supported for properties of a class (not component) -->
   <!ATTLIST set node CDATA #IMPLIED>
   <!ATTLIST set embed-xml (true|false) "true">


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 6:25 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yep, you're right. It was added in 3.1beta1; I'm using 3.0.5 so it's not in my dtd. My earlier comments still apply as an alternative way of making sets immutable, though.

Double check that you're using matching DTDs and jars: the current DTD with a 3.1 or earlier jar obviously won't support this. Beyond that, I can't help, sorry.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 26, 2006 9:41 pm 
Beginner
Beginner

Joined: Mon Aug 01, 2005 3:10 pm
Posts: 22
And you are right too, I was using an older jar (3.0.5) and refering to documentation related to 3.1. Thanks for pointing that out so I know where the error comes from.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 7:14 am 
Newbie

Joined: Mon May 23, 2005 4:23 am
Posts: 4
Was the issue fixed in hibernate 3.1.1 for map as well as for set collections?
I constantly have warnings about read-only cache configured for mutable classes.

My mapping file is below (hibernate 3.1.1):

<hibernate-mapping default-lazy="false">
<class name="CollateralType" table="collateral_type" mutable="false">
<cache usage="read-only"/>
<id name="id" type="string" access="field">
...
<map name="texts" table="collateral_type_tx" access="field" mutable="false">
<cache usage="read-only"/>
<key column="pid"/>
<index column="lang" type="string" length="2"/>
<element column="text" type="string" length="100" not-null="true" />
</map>
</class>
</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 30, 2006 6:27 pm 
Expert
Expert

Joined: Thu Dec 23, 2004 9:08 pm
Posts: 2008
Yes. Mutable has been added for all collection types in 3.1beta1.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 04, 2007 12:53 pm 
Newbie

Joined: Wed Apr 04, 2007 12:47 pm
Posts: 1
I've experienced the problem with the warning on immutable sets as well, so I cracked open the sourcecode for the version I'm using 3.1.2 and tracked down where the warning occurs.

It looks like in the class, the 'mutability' of all collections is hardcoded to true. I'm pasting a snippit from the source I was looking at for resource org.hibernate.impl.SessionFactoryImpl:

Code:
CacheConcurrencyStrategy cache = CacheFactory.createCache(
         model.getCacheConcurrencyStrategy(),
            model.getCacheRegionName(),
            true,
            settings,
            properties
         );


The third parameter in the above snippit is hardcoded to true, even though the provided model may have its mutable flag set to false. Within the createCache() method, if the mutability is set to true, and the concurrency strategy is read-only, you'll get the telltale warning MrSqueezles posted.

I'm not certain if this is a bug or an intended hardcoding, but was hoping someone with a bit more familiarity might be able to comment on this and let me know which is the case.

Thanks,

Josh Ladieu


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