I have two named queries that run iteratively within the same session, query a runs then b then a again, etc. The first time through both run fine, but when query a tries to run again (with new where clause variables), it throws a "Can't write to a readonly object" exception. If I clear the session, it runs fine. Why would it try to update the
Hibernate version:2.1.6
Mapping documents: <class name="PopulationElement" table="wtg_population" > <jcs-cache usage="read-only"/> <id name="id" type="long" column="POPULATION_ID"> <generator class="assigned"/> </id> <property name="serviceId" column="SERVICE_CODE"/> <property name="surveyId" column="SURVEY_CODE"/> <property name="sampleGeoGnmbr" column="SMPL_GEO_GNMBR"/> <property name="value" column="POP_VALUE" type="long"/> <property name="ethnicCode" column="ETHNIC_CODE"/> <property name="gender" column="GENDER_CODE"/> <property name="startAge" column="START_AGE"/> <property name="endAge" column="END_AGE"/> </class> <class name="Target" table="SMPL_GEO_TRGTS"> <jcs-cache usage="read-only"/> <composite-id> <key-property name="surveyId" column="SRVY_ID"/> <key-property name="sampleGeoGnmbr" column="SMPL_GEO_GNMBR"/> </composite-id> <property name="target" column="INTAB_TRGT_CNT"/> </class> <query name="com.arbitron.geodemo.Populations"><![CDATA[Select distinct pe from PopulationElement pe where pe.serviceId = :serviceId and pe.surveyId = :surveyId and pe.sampleGeoGnmbr in (:sampleGeoGnmbr) ]]> </query> <query name="com.arbitron.geodemo.Targets"><![CDATA[Select distinct tg from Target tg where tg.surveyId = :surveyId and tg.sampleGeoGnmbr in (:sampleGeoGnmbr) ]]> </query>
Code between sessionFactory.openSession() and session.close(): Query q = sess.getNamedQuery("com.arbitron.geodemo.Populations"); q.setString("serviceId", "RADIO"); q.setString("surveyId", "FA03"); q.setParameterList("sampleGeoGnmbr", sampleGeos, new net.sf.hibernate.type.LongType()); List qlist= q.list();
Different method: Query targetQuery = sess.getNamedQuery("com.arbitron.geodemo.Targets"); targetQuery.setString("surveyId", "FA03"); targetQuery.setParameterList("sampleGeoGnmbr",cId,new net.sf.hibernate.type.LongType()); targetIter = targetQuery.list()
Full stack trace of any exception that occurs: 11526 ERROR [AWT-EventQueue-0] () - Application attempted to edit read only item: 560166 java.lang.UnsupportedOperationException: Can't write to a readonly object at net.sf.hibernate.cache.ReadOnlyCache.lock(ReadOnlyCache.java:36) at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:50) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2372) at net.sf.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:1811) at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1568) at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1533) at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39) at com.arbitron.geodemo.PopulationHelper.<init>(PopulationHelper.java:68) at com.arbitron.currency.weight.diary.ModelSetFactory.getCountyPopHelper(ModelSetFactory.java:805) at com.arbitron.currency.weight.diary.ModelSetFactory.createNonEthnicModel(ModelSetFactory.java:698) at com.arbitron.currency.weight.diary.ModelSetFactory.createModels(ModelSetFactory.java:638) at com.arbitron.currency.weight.diary.ModelSetFactory.createModelSet(ModelSetFactory.java:481) at com.arbitron.currency.weight.diary.ModelSetFactory.<init>(ModelSetFactory.java:447) at com.arbitron.currency.weighting.ui.WeightingRunUI.getModelSet(WeightingRunUI.java:195) at com.arbitron.currency.weighting.ui.WeightingRunUI.determine(WeightingRunUI.java:287) at com.arbitron.currency.weighting.ui.WeightingRunUI.actionPerformed(WeightingRunUI.java:251) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) java.lang.NullPointerException at com.arbitron.geodemo.PopulationHelper.<init>(PopulationHelper.java:74) at com.arbitron.currency.weight.diary.ModelSetFactory.getCountyPopHelper(ModelSetFactory.java:805) at com.arbitron.currency.weight.diary.ModelSetFactory.createNonEthnicModel(ModelSetFactory.java:698) at com.arbitron.currency.weight.diary.ModelSetFactory.createModels(ModelSetFactory.java:638) at com.arbitron.currency.weight.diary.ModelSetFactory.createModelSet(ModelSetFactory.java:481) at com.arbitron.currency.weight.diary.ModelSetFactory.<init>(ModelSetFactory.java:447) at com.arbitron.currency.weighting.ui.WeightingRunUI.getModelSet(WeightingRunUI.java:195) at com.arbitron.currency.weighting.ui.WeightingRunUI.determine(WeightingRunUI.java:287) at com.arbitron.currency.weighting.ui.WeightingRunUI.actionPerformed(WeightingRunUI.java:251) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Name and version of the database you are using:Oracle 9i
Debug level Hibernate log excerpt:
|