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: one-to-many Oracle Blob IllegalStateException
PostPosted: Thu Jan 19, 2006 8:24 pm 
Newbie

Joined: Thu Jan 19, 2006 7:16 pm
Posts: 5
Ok, after a bunch of work getting Blobs to work in Oracle (by simply using the Oracle 10 drivers!) I am getting an IllegalStateException. This only occurs when updating a parent object with a set of Children with Blob properties added to a non-empty SortedSet. This exception does not occur when the SortedSet is empty and I add one (or multiple) Child Objects and call saveorupdate() (litteraly both save or update) on the parent. Can someone help me with a solution to this problem?

Let me restate the problem if the previous explanation was foggy...
    I have a Parent Object with a one-to-many association with cascade="all" to its Children Objects.
    These Children Objects have Blob propertys (Objects).
    When I saveorupdate a Parent after adding Children Objects to the on-to-many set and the set was not empty to start with I get an IllegalStateException saying that I cant access Blobs after serialization.


Hibernate version:
3.1

Mapping documents:
Ok, here goes:

Parent:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="fmtnm.eodms.entities.EO" table="DATA_EO">
      <id name="id" column="ID" type="long">
         <generator class="sequence">
            <param name="sequence">HIBERNATE_EO_SEQUENCE</param>
         </generator>
        </id>
...

      <set sort="natural" name="files"  cascade="all">
         <key column="EO_ID"/>
         <one-to-many class="fmtnm.eodms.entities.EODoc"/>
      </set>

...
      
   </class>   
</hibernate-mapping>


Child:

Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping
PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
   <class name="fmtnm.eodms.entities.EODoc" lazy="false" table="EODOCS">
      
      <id name="id" type="long" column="ID">
         <generator class="sequence">
            <param name="sequence">HIBERNATE_EODOC_SEQUENCE</param>
         </generator>
      </id>
      <property name="eoId" type="long">
         <column name="EO_ID"/>
      </property>

...
      
      <property name="file" type="blob">
         <column name="OBJECT_FILE"/>
      </property>
      
   </class>
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Code:
Session session = null;
        Transaction tx = null;
        try {
            session = HibernateFactory.getSessionFactory().openSession();

            tx = session.beginTransaction();

            session.saveOrUpdate(obj);
           
            session.flush();

            tx.commit();
        }
        catch(StaleObjectStateException e)
        {
            if(tx != null)
                tx.rollback();
            throw new HibernateException("There was a problem saving, either you hit refresh or someone else is editing this form.  The current form has been reloaded.");
        }
        catch (RuntimeException e)
        {
            if(tx != null)
                tx.rollback();
            throw e;
        }
        finally {
            if (session != null)
                session.close();
        }


Full stack trace of any exception that occurs:

java.lang.IllegalStateException: Blobs may not be accessed after serialization
at org.hibernate.lob.SerializableBlob.getWrappedBlob(SerializableBlob.java:45)
at org.hibernate.type.BlobType.set(BlobType.java:38)
at org.hibernate.type.BlobType.nullSafeSet(BlobType.java:117)
at org.hibernate.persister.entity.AbstractEntityPersister.dehydrate(AbstractEntityPersister.java:1826)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2172)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2118)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2374)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:84)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:243)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:227)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:296)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:980)
at fmtnm.eodms.db.Db.SaveOrUpdate(Db.java:30)
at fmtnm.eodms.view.pages.EOEdit.saveSubmit(EOEdit.java:381)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.tapestry.listener.ListenerMap.invokeTargetMethod(ListenerMap.java:257)
at org.apache.tapestry.listener.ListenerMap.access$100(ListenerMap.java:46)
at org.apache.tapestry.listener.ListenerMap$SyntheticListener.invoke(ListenerMap.java:97)
at org.apache.tapestry.listener.ListenerMap$SyntheticListener.actionTriggered(ListenerMap.java:102)
at org.apache.tapestry.form.Submit.renderComponent(Submit.java:80)
at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:857)
at org.apache.tapestry.AbstractComponent.renderBody(AbstractComponent.java:624)
at org.apache.tapestry.form.Form.renderComponent(Form.java:362)
at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:857)
at org.apache.tapestry.form.Form.rewind(Form.java:568)
at org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:432)
at org.apache.tapestry.form.Form.trigger(Form.java:582)
at org.apache.tapestry.engine.DirectService.service(DirectService.java:169)
at org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:872)
at org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:197)
at org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:326)
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:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Unknown Source)

Name and version of the database you are using:

Oracle 9i with Oracle 10 Driver

The generated SQL (show_sql=true):
Hibernate: select HIBERNATE_EODOC_SEQUENCE.nextval from dual
Hibernate: insert into EODOCS (EO_ID, FILENAME, OBJECT_FILE, ID) values (?, ?, ?, ?)
Hibernate: update DATA_EO set VERSION=?, DRAWING_ID=?, NAME=?, REVISION=?, STATUS=?, DISPOSITION=?, WIPQUANTITY=?, USER_EMAIL_NOTIFY_DATE=?, CLASSIFICATION=?, PART_CLASSIFICATION=?, ORIGINATOR=?, CREATE_DATE=?, NEXT_ASSEMBLY=?, EFFECTIVITY_COMMENT=?, EFFECTIVITY_DATE=?, LOM_CHANGE=?, EO_LEVEL=?, USQ_REVIEW_REQUEST=?, APPROVED_FOR_OPEN_BY=?, APPROVED_FOR_OPEN_BY_DATE=?, APPROVED_FOR_CLOSE_BY=?, APPROVED_FOR_CLOSE_BY_DATE=?, OPENED_BY=?, OPENED_BY_DATE=?, CLOSED_BY=?, CLOSED_BY_DATE=?, CANCELED_BY=?, CANCELED_BY_DATE=?, LAST_MODIFIED_BY=?, LAST_MODIFIED_BY_DATE=?, CHANGE_DESCRIPTION=? where ID=? and VERSION=?
Hibernate: update EODOCS set EO_ID=?, FILENAME=?, OBJECT_FILE=? where ID=?

Debug level Hibernate log excerpt:
N/A


Top
 Profile  
 
 Post subject: Figured this problem out
PostPosted: Fri Jan 20, 2006 3:54 pm 
Newbie

Joined: Thu Jan 19, 2006 7:16 pm
Posts: 5
Well, after a day of trying different settings and screwing around with the JDBC driver, I looked at my post again and tried to determine the problem. Low and behold it was stareing me right in the face. As you can see, there is an insert dont to EODocs before the update to DATA_EO... then another update to EODoc. This second update it probably to populate the EO's id or something. Anyways, I simply set update="false" on the Blob and the IllegalStateException is no longer thrown. Well, if you guys have any questions about Blobs, Oracle, and hibernate feel free to ask me. I feel like an expert after all this running around.


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.