Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2011
    Posts
    1

    Unanswered: Hibernate returning an error when trying to Update a record in mysql database

    I am using mysql database as a backend and Hibernate3 as a DAO layer to deal with the database.
    The problem I am facing is record is not updated into the database. I am not sure whether it is inserted in first place because dont' have sufficient logs to confirm. Still it probably has to do with some transaction treament in cluster vs non-cluster environment in MySql.

    20110408 114539261+0000 ERROR;[logging.LoggingAspect;124] UncaughtException detail=Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
    org.springframework.orm.hibernate3.HibernateOptimi sticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
    at org.springframework.orm.hibernate3.SessionFactoryU tils.convertHibernateAccessException(SessionFactor yUtils.java:672)
    at org.springframework.orm.hibernate3.HibernateAccess or.convertHibernateAccessException(HibernateAccess or.java:412)
    at org.springframework.orm.hibernate3.HibernateTempla te.doExecute(HibernateTemplate.java:424)
    at org.springframework.orm.hibernate3.HibernateTempla te.executeWithNativeSession(HibernateTemplate.java :374)
    at org.springframework.orm.hibernate3.HibernateTempla te.update(HibernateTemplate.java:716)
    at org.springframework.orm.hibernate3.HibernateTempla te.update(HibernateTemplate.java:712)
    at com.openwave.richmail.dao.MigrationDao.update(Migr ationDao.java:96)
    at com.openwave.richmail.contact.migration.MigrationS tore.updateEntry(MigrationStore.java:116)
    at com.openwave.richmail.contact.migration.MssToVoxAd dressMigrator.migrate(MssToVoxAddressMigrator.java :174)
    at com.openwave.richmail.web.ContactListController.li stAll(ContactListController.java:98)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.doInvokeMethod(HandlerMethodInv oker.java:421)
    at org.springframework.web.bind.annotation.support.Ha ndlerMethodInvoker.invokeHandlerMethod(HandlerMeth odInvoker.java:136)
    at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.invokeHandlerMethod(An notationMethodHandlerAdapter.java:326)
    at org.springframework.web.servlet.mvc.annotation.Ann otationMethodHandlerAdapter.handle(AnnotationMetho dHandlerAdapter.java:313)
    at org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:875)
    at org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:807)
    at org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:571)
    at org.springframework.web.servlet.FrameworkServlet.d oPost(FrameworkServlet.java:511)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at com.openwave.richmail.util.JSONTaglibFilter.doFilt erInternal(JSONTaglibFilter.java:56)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.springframework.web.filter.CharacterEncodingFi lter.doFilterInternal(CharacterEncodingFilter.java :96)
    at org.springframework.web.filter.OncePerRequestFilte r.doFilter(OncePerRequestFilter.java:76)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:433)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:568)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker****n (JIoEndpoint.java:447)
    at java.lang.Thread****n(Thread.java:619)
    Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
    at org.hibernate.jdbc.Expectations$BasicExpectation.c heckBatched(Expectations.java:61)
    at org.hibernate.jdbc.Expectations$BasicExpectation.v erifyOutcome(Expectations.java:46)
    at org.hibernate.jdbc.BatchingBatcher.checkRowCounts( BatchingBatcher.java:68)
    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch( BatchingBatcher.java:48)
    at org.hibernate.jdbc.AbstractBatcher.executeBatch(Ab stractBatcher.java:246)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:266)
    at org.hibernate.engine.ActionQueue.executeActions(Ac tionQueue.java:168)
    at org.hibernate.event.def.AbstractFlushingEventListe ner.performExecutions(AbstractFlushingEventListene r.java:298)
    at org.hibernate.event.def.DefaultFlushEventListener. onFlush(DefaultFlushEventListener.java:27)
    at org.hibernate.impl.SessionImpl.flush(SessionImpl.j ava:1000)
    at org.springframework.orm.hibernate3.HibernateAccess or.flushIfNecessary(HibernateAccessor.java:390)
    at org.springframework.orm.hibernate3.HibernateTempla te.doExecute(HibernateTemplate.java:420)
    ... 43 more



    The full stack trace printed here. I have searched through forum but could not find a close answer to my situation.

    I would also like to know about the different loggers that can be used to get more information.

    Here is the sequence I follow:
    1. Insert a record into database using getHibernateTemplate().save(entity);
    2. Trying to update the entry from #1 using
    getHibernateTemplate().update(entity);

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    what an odd question.. you've placed the java stack trace in the MySQL forum, usually the stack trace is only useful if you have the source code.
    you are using hibernate3 as your data abstraction layer
    yet you havent' rpovided the SQL or the table design

    ..its kinda hard to figure out what is going wrong, short of having crystal balls to divine the error from the aura(s)

    if I were you Od want to prove to myself the SQL is valid and actaullay should and does do "something". ie prove that the requet tot he SQL engine is OK
    after that I'd want to start delving into the Java stuff to find out whay the proven SQL isn't working
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •