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)
|