Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Could not synchronize database state with session error.
PostPosted: Mon May 21, 2012 2:07 pm 
Newbie

Joined: Thu Jan 19, 2012 1:21 pm
Posts: 12
Can anyone help me with the error listed below?
I get it while attempting to update an entry using hibernate.
I am getting: Could not synchronize database state with session

Here is the code I am calling - pretty straight forward update.
Code:
    public int updatePolygonPoint( long polyPointId, double lat, double lon )
    {
        System.out.println( "<DbHelper.updatePolygonPoint> updating Polygon Point "+polyPointId+", lat = "+lat+", lon = "+lon );
        int stat = 0;
        String latStr = df.format(lat);
        String lonStr = df.format(lon);
        TbPolygonPoint point = null;
        try
        {
            BigDecimal bdLat = new BigDecimal(latStr);
            BigDecimal bdLon = new BigDecimal(lonStr);
            org.hibernate.Transaction tx = session.beginTransaction();
            point = (TbPolygonPoint)session.get(TbPolygonPoint.class, polyPointId);
            point.setDcLatitude(bdLat);
            point.setDcLongitude(bdLon);
            try
            {
                session.update(point);
                tx.commit();
                this.session = HibernateUtil.getSessionFactory().openSession();
                stat = 1;
            }
            catch(Exception e)
            {
                tx.rollback();
                e.printStackTrace();
                status = e.getMessage();
                stat = -1;
            }
        }
        catch( Exception ex )
        {
            ex.printStackTrace();
            status = ex.getMessage();
            stat = -1;
        }
        return stat;
    }


Here is the error I get:
Code:
[#|2012-05-21T12:29:41.250-0500|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|--------------------- <MappingSessionBean.savePolyAction> edit mode|#]

[#|2012-05-21T12:29:41.250-0500|INFO|oracle-glassfish3.1.1|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=18;_ThreadName=Thread-2;|<DbHelper.updatePolygonPoint> updating Polygon Point 1168, lat = 32.96394955977022, lon = -96.84266845767212|#]

[#|2012-05-21T12:29:41.703-0500|WARNING|oracle-glassfish3.1.1|org.hibernate.util.JDBCExceptionReporter|_ThreadID=18;_ThreadName=Thread-2;|SQL Error: 0, SQLState: null|#]

[#|2012-05-21T12:29:41.703-0500|SEVERE|oracle-glassfish3.1.1|org.hibernate.util.JDBCExceptionReporter|_ThreadID=18;_ThreadName=Thread-2;|A result set was generated for update.|#]

[#|2012-05-21T12:29:41.703-0500|SEVERE|oracle-glassfish3.1.1|org.hibernate.event.def.AbstractFlushingEventListener|_ThreadID=18;_ThreadName=Thread-2;|Could not synchronize database state with session
org.hibernate.exception.GenericJDBCException: could not update: [hibernate.TbPolygonPoint#1168]
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
   at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
   at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at hibernate.DbHelper.updatePolygonPoint(DbHelper.java:2180)
   at rmsbackoffice.MappingSessionBean.savePolyAction(MappingSessionBean.java:2435)
   at rmsbackoffice.MappingSessionBean.confirmAddPolyContinueAction(MappingSessionBean.java:2274)
   at rmsbackoffice.org$jboss$weld$bean-RMSBackOfficeDEV-ManagedBean-class_rmsbackoffice$MappingSessionBean_$$_WeldClientProxy.confirmAddPolyContinueAction(org$jboss$weld$bean-RMSBackOfficeDEV-ManagedBean-class_rmsbackoffice$MappingSessionBean_$$_WeldClientProxy.java)
   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 com.sun.el.parser.AstValue.invoke(AstValue.java:234)
   at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
   at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
   at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
   at javax.faces.event.MethodExpressionActionListener.processAction(MethodExpressionActionListener.java:153)
   at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
   at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
   at javax.faces.component.UICommand.broadcast(UICommand.java:300)
   at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
   at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
   at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
   at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
   at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
   at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
   at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
   at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
   at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
   at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
   at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)
   at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)
   at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)
   at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)
   at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)
   at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
   at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
   at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
   at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
   at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
   at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
   at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
   at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
   at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
   at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
   at java.lang.Thread.run(Thread.java:662)
Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
   at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:187)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:401)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:338)
   at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5574)
   at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1734)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:179)
   at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:154)
   at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate(SQLServerPreparedStatement.java:306)
   at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
   at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2403)
   ... 58 more
|#]



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.