-->
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: TransientObjectException ?
PostPosted: Wed Oct 13, 2004 3:51 am 
Beginner
Beginner

Joined: Thu Sep 02, 2004 9:17 am
Posts: 21
Hi there

I am using Spring and Hibernate for a web application I am writing. The application is for administering "Constructions". For example, buildings, bridges etc, which consist of many sub-parts. I am not sure if the problem I am seeing is Hibernate or Spring related, so please bear with me...

I have a JSP where a user can view a "Construction" object. And where the user can edit and create a new "Construction".

This was working ok, but a little slowly, so I started to investigate "lazy-loading". This sped things up remarkably, but now I have a new problem...

To enable lazy-loading to work in a web-application it appears one must maintain a Hibernate session over the entire request, to enable the JSP to completely render the "Construction" object for example. This seems to give a problem when I want to create a new "Construction".

For creating a new Construction I instantiate an "empty" Construction object which I supply to the JSP (which then renders empty fields for the user to fill in). This works fine unless I use lazy-loading (and Spring's OpenSessionInViewInterceptor). Then I get an error, which I think has something to do with Hibernate trying to synchronise my empty object with the database (?)

Does anyone have any ideas or help about this?

Thanks, Peter


Hibernate version:
2.1.6

Full stack trace of any exception that occurs:
2004-10-13 09:46:16,500 ERROR [net.sf.hibernate.impl.SessionImpl] - <Could not synchronize database state with session>
net.sf.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: dk.ciber.danbro.facility.impl.DefaultConstructionNode
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(SessionImpl.java:2768)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(SessionImpl.java:2760)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:47)
at net.sf.hibernate.collection.AbstractCollectionPersister.writeElement(AbstractCollectionPersister.java:384)
at net.sf.hibernate.collection.Set.writeTo(Set.java:226)
at net.sf.hibernate.collection.AbstractCollectionPersister.insertRows(AbstractCollectionPersister.java:607)
at net.sf.hibernate.impl.ScheduledCollectionUpdate.execute(ScheduledCollectionUpdate.java:49)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2418)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2374)
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 org.springframework.orm.hibernate.HibernateTemplate$21.doInHibernate(HibernateTemplate.java:402)
at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:176)
at org.springframework.orm.hibernate.HibernateTemplate.executeFind(HibernateTemplate.java:196)
at org.springframework.orm.hibernate.HibernateTemplate.find(HibernateTemplate.java:399)
at dk.ciber.danbro.common.impl.HibernateDao.query(HibernateDao.java:112)
at dk.ciber.danbro.catalogue.impl.DefaultCatalogueManager.getCatalogueNodes(DefaultCatalogueManager.java:51)
at dk.ciber.danbro.facility.web.SimpleFacilityFormController.generateDataLists(SimpleFacilityFormController.java:171)
at dk.ciber.danbro.facility.web.SimpleFacilityFormController.referenceData(SimpleFacilityFormController.java:119)
at org.springframework.web.servlet.mvc.SimpleFormController.referenceData(SimpleFormController.java:164)
at org.springframework.web.servlet.mvc.AbstractFormController.showForm(AbstractFormController.java:365)
at org.springframework.web.servlet.mvc.AbstractFormController.showForm(AbstractFormController.java:342)
at org.springframework.web.servlet.mvc.SimpleFormController.showForm(SimpleFormController.java:190)
at org.springframework.web.servlet.mvc.AbstractFormController.showNewForm(AbstractFormController.java:284)
at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:240)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:121)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:485)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:322)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:732)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:688)
at java.lang.Thread.run(Thread.java:534)


Top
 Profile  
 
 Post subject: TransientObjectException
PostPosted: Fri Oct 29, 2004 12:46 pm 
Newbie

Joined: Fri Feb 20, 2004 12:15 pm
Posts: 8
Have you put 'cascade="all"' in your 'collection' (set, list, map...) in your .hbm file?


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.