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.  [ 4 posts ] 
Author Message
 Post subject: Could not synchronize database state with session
PostPosted: Tue Apr 20, 2004 10:51 am 
Newbie

Joined: Thu Apr 01, 2004 2:19 pm
Posts: 14
I have a struts application. When the user requests for Plan information, I use Hibernate to load the object from database and then I fill the values to be displayed to the user. The user modifies these values and then when user sumits the data, I create the object again from scratch with the user values and try to update the database. This operation fails. I get the following exception:

net.sf.hibernate.TransientObjectException: object references an unsaved transien
t instance - save the transient instance before flushing: com.pepsico.mya.bonus.
om.impl.BusinessRuleImpl
at net.sf.hibernate.impl.SessionImpl.throwTransientObjectException(Sessi
onImpl.java:2652)
at net.sf.hibernate.impl.SessionImpl.getEntityIdentifierIfNotUnsaved(Ses
sionImpl.java:2644)
at net.sf.hibernate.type.EntityType.getIdentifier(EntityType.java:66)
at net.sf.hibernate.type.ManyToOneType.nullSafeSet(ManyToOneType.java:46
)
at net.sf.hibernate.persister.EntityPersister.dehydrate(EntityPersister.
java:394)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:651)
at net.sf.hibernate.persister.EntityPersister.update(EntityPersister.jav
a:625)
at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:52
)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2262)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2187)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at com.pepsico.mya.bonus.persistence.PersistenceManagerSupport.save(Pers
istenceManagerSupport.java:218)
at com.pepsico.mya.bonus.persistence.impl.PlanPersistenceManager.save(Pl
anPersistenceManager.java:210)
at com.pepsico.mya.bonus.struts.AbstractSaveAction.execute(AbstractSaveA
ction.java:31)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 12:58 pm 
Newbie

Joined: Tue Oct 21, 2003 6:14 pm
Posts: 11
Your case looks like you are doing these operations in different transactions/sessions.

In a given session if u want to update some object, you either query that
object in that session and update the properties or if you have an object
which was queried in a different session or case like urs, you might have
to associate the object with the second session before you can call update


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 20, 2004 2:10 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
please show both requests code (of course simplify it before)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 21, 2004 4:45 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
And mapping, there is probably a missing cascade attribute somewhere

_________________
Emmanuel


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