aspose file tools*
The moose likes Object Relational Mapping and the fly likes TransientObjectException in Hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "TransientObjectException in Hibernate" Watch "TransientObjectException in Hibernate" New topic
Author

TransientObjectException in Hibernate

Sreenivas Reddy Tatikunta
Greenhorn

Joined: Aug 23, 2011
Posts: 24

Hello All,

Can anyone please expain the below Hibernate Exception. What are the scenario this exception will raise. I searched so many forums but i could not able to figured out the problem.

org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.flow.db.Address

17:17:43,526 ERROR [STDERR] org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.flow.db.Address
at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:242)
at org.hibernate.type.EntityType.getIdentifier(EntityType.java:430)
at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:265)
at org.hibernate.type.TypeFactory.findDirty(TypeFactory.java:619)
at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3151)
at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:501)
at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:227)
at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:150)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
at org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:58)
at org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:996)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1717)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
at org.hibernate.impl.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:835)
at com.enet.dao.registration.VoterRegistrationDAO.getMaxSeqNumForAddrChanage(VoterRegistrationDAO.java:157)
at com.enet.dao.registration.VoterRegistrationDAO.addNewVoter(VoterRegistrationDAO.java:73)
at com.enet.service.registration.VoterRegistrationService.addNewVoter(VoterRegistrationService.java:74)
at com.enet.bean.registration.VoterRegistrationBean.addNewVoter(VoterRegistrationBean.java:27)
at com.enet.delegate.registration.VoterRegistrationDelegate.addNewVoter(VoterRegistrationDelegate.java:37)
at com.enet.struts.action.registration.AcceptNewVoterRegAction.executeContinue(AcceptNewVoterRegAction.java:37)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:235)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:158)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662)


But i tested in One senario: When checking the if condition then that time excetption is raised. Without condition it is saving object Perfectly.

Address address= item.getVoterDetails();
if(address !=null){
..............
............
session.save(address);
}

working fine for the above case.

But when i am adding the new condition exception is raising..

Address address= item.getVoterDetails();
if(address !=null && address .getStreetName() != null && address .getStreetName().trim().length() >0 ){
..............
............
session.save(address);
}


please Help me out..

Thanks in Advacne..


Best Regards,
Sreenivas Reddy Tatikunta
Sreenivas Reddy Tatikunta
Greenhorn

Joined: Aug 23, 2011
Posts: 24

Can any one please help. It's very urgent.

Regards,
Sreenivas Reddy.T
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855


If this is the reason then you have either streetName null/empty, have you tried fixing that?


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sreenivas Reddy Tatikunta
Greenhorn

Joined: Aug 23, 2011
Posts: 24

Yes I tried for this also again showing same problem.

Is there any another way we can resolve this problem???.

Regards,
Sreenivas Reddy.T
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3855

Yes I tried for this also again showing same problem.

With that how the code looks and what problem you get? Most probably your initial object not saved. Have you tried to debug whether your save() method get executed for that instance? Post the new code with any errors.
 
 
subject: TransientObjectException in Hibernate