-->
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: Sat Mar 17, 2007 2:05 am 
Newbie

Joined: Thu Mar 15, 2007 2:27 am
Posts: 2
Hi!
This is senthil, i'm face below Error can anyone help,

CODE USED:
sessionFactory = new Configuration().configure().buildSessionFactory();
public static Session getNewSession() throws HibernateException {
Session s = sessionFactory.openSession();
s.setCacheMode(CacheMode.IGNORE);
s.setFlushMode(FlushMode.COMMIT);
session.set(s);
return s;
}

actually i'm trying to insert a value for object to another object,while doing so i'm finding this

ERROR DISPLAYED ON SERVER CONSOLE:
13:13:25,843 ERROR AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not insert: [com.infony.model.PurRequisitionDetails]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:69)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2068)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2417)
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:51)
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:140)
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:877)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:344)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
at com.infony.pages.PurchaseRequisitionPage.saveRec(PurchaseRequisitionPage.java:717)
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:585)
at org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeTargetMethod(ListenerMethodInvokerImpl.java:214)
at org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeListenerMethod(ListenerMethodInvokerImpl.java:155)
at org.apache.tapestry.listener.ListenerMethodInvokerImpl.searchAndInvoke(ListenerMethodInvokerImpl.java:124)
at org.apache.tapestry.listener.ListenerMethodInvokerImpl.invokeListenerMethod(ListenerMethodInvokerImpl.java:69)
at org.apache.tapestry.listener.SyntheticListener.actionTriggered(SyntheticListener.java:51)
at org.apache.tapestry.listener.ListenerInvokerTerminator.invokeListener(ListenerInvokerTerminator.java:51)
at $ListenerInvoker_11153d8729c.invokeListener($ListenerInvoker_11153d8729c.java)
at org.apache.tapestry.form.AbstractSubmit$1.run(AbstractSubmit.java:88)
at org.apache.tapestry.form.FormSupportImpl.runDeferredRunnables(FormSupportImpl.java:608)
at org.apache.tapestry.form.FormSupportImpl.rewind(FormSupportImpl.java:589)
at org.apache.tapestry.form.Form.renderComponent(Form.java:226)
at $Form_8.renderComponent($Form_8.java)
at org.apache.tapestry.AbstractComponent.render(AbstractComponent.java:617)
at org.apache.tapestry.form.Form.rewind(Form.java:327)
at org.apache.tapestry.engine.RequestCycle.rewindForm(RequestCycle.java:439)
at org.apache.tapestry.form.Form.trigger(Form.java:338)
at org.apache.tapestry.engine.DirectService.triggerComponent(DirectService.java:146)
at org.apache.tapestry.engine.DirectService.service(DirectService.java:132)
at $IEngineService_11153d872f4.service($IEngineService_11153d872f4.java)
at org.apache.tapestry.services.impl.EngineServiceOuterProxy.service(EngineServiceOuterProxy.java:66)
at org.apache.tapestry.engine.AbstractEngine.service(AbstractEngine.java:248)
at org.apache.tapestry.services.impl.InvokeEngineTerminator.service(InvokeEngineTerminator.java:60)
at $WebRequestServicer_11153d872d0.service($WebRequestServicer_11153d872d0.java)
at $WebRequestServicer_11153d872cc.service($WebRequestServicer_11153d872cc.java)
at org.apache.tapestry.services.impl.WebRequestServicerPipelineBridge.service(WebRequestServicerPipelineBridge.java:56)
at $ServletRequestServicer_11153d872b2.service($ServletRequestServicer_11153d872b2.java)
at org.apache.tapestry.request.DecodedRequestInjector.service(DecodedRequestInjector.java:55)
at $ServletRequestServicerFilter_11153d872ae.service($ServletRequestServicerFilter_11153d872ae.java)
at $ServletRequestServicer_11153d872b4.service($ServletRequestServicer_11153d872b4.java)
at org.apache.tapestry.multipart.MultipartDecoderFilter.service(MultipartDecoderFilter.java:52)
at $ServletRequestServicerFilter_11153d872ac.service($ServletRequestServicerFilter_11153d872ac.java)
at $ServletRequestServicer_11153d872b4.service($ServletRequestServicer_11153d872b4.java)
at org.apache.tapestry.services.impl.SetupRequestEncoding.service(SetupRequestEncoding.java:53)
at $ServletRequestServicerFilter_11153d872b0.service($ServletRequestServicerFilter_11153d872b0.java)
at $ServletRequestServicer_11153d872b4.service($ServletRequestServicer_11153d872b4.java)
at $ServletRequestServicer_11153d872a6.service($ServletRequestServicer_11153d872a6.java)
at org.apache.tapestry.ApplicationServlet.doService(ApplicationServlet.java:123)
at org.apache.tapestry.ApplicationServlet.doPost(ApplicationServlet.java:168)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:286)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:258)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:256)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:210)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:196)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:175)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
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:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:974)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:207)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:647)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:497)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:575)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:649)
at java.lang.Thread.run(Thread.java:595)


Regards,
senthil.D


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 18, 2007 5:14 pm 
Newbie

Joined: Tue Mar 06, 2007 1:35 pm
Posts: 10
Hi there.

Well, not sure if I really understand your problem, but following the stacktrace, it seems you're trying to create (insert) an object with duplicate values on attributes part of an integrity constraint. If you're trying to update an object, first it must has the id setted and second you must use the update method instead of save.

-cris


Top
 Profile  
 
 Post subject: Reg:Data synchorization problem
PostPosted: Tue Mar 20, 2007 7:42 am 
Newbie

Joined: Thu Mar 15, 2007 2:27 am
Posts: 2
Hi!
Thanks for ur reply, but i'm not facing duplicate entry problem,
actually i'm using a mutiple objects in a single session, if i'm trying to save or update one object it will reflected in other objects too so in such circumstance i having finding this error "Could not synchronize database state with session"


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 9:41 am 
Newbie

Joined: Tue Mar 06, 2007 1:35 pm
Posts: 10
So in this case you should consider using cascade in your entities relationships. If you have an User class which has an attribute of the type Address marked as @OneToOne (for instance) and you don't want to save it manually, in the relation annotation in the User class you should declare something like @Cascade(CascadeType.ALL).

HTH!


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.