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.  [ 2 posts ] 
Author Message
 Post subject: Batch update returned unexpected row count from update [0];
PostPosted: Mon Feb 07, 2011 7:00 pm 
Beginner
Beginner

Joined: Sun Jan 30, 2011 8:14 am
Posts: 24
Hi guys,
I've a strange issue, please help me to understand.
I've problem updating an object with hibernate and Java.
Object is user with increment id, name and surname and it's stored in the currentUser property.
This is my update


Code:
private User currentUser;
public Status.eStatus Update()
    {
        try
        {
            Session session = HibernateUtil.getSessionFactory().openSession();
            session.beginTransaction();
            session.update(this.currentUser);
            session.getTransaction().commit();
            session.close();
        }
        catch (HibernateException he) {
            he.printStackTrace();
            throw he;
        }
        return Status.eStatus.SUCCESS;

    }


This is my exception (please note that currentUser is correct , that is has update field, only db is not updated, with this exception:

Code:
GRAVE: Could not synchronize database state with session
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1


PLease note that insert and delete method works correctly, only update not. Maybe the increment id the problem?
Please help me to understand


Top
 Profile  
 
 Post subject: Re: Batch update returned unexpected row count from update [0];
PostPosted: Wed Mar 23, 2011 6:23 am 
Newbie

Joined: Tue Dec 01, 2009 4:38 am
Posts: 2
I'm facing the same problem like yours, I think what hibernate is trying to tell us is the Session can't sync with the state in database.

[What I did to duplicate this problem]
- it all works fine until I manually delete some records from back-end database while the program still running,
then it throws following exception ...

Code:
     [java] org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
     [java]    at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
     [java]    at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
     [java]    at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)
     [java]    at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
     [java]    at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:56)
     [java]    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2431)
     [java]    at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2335)
     [java]    at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2635)
     [java]    at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:115)
     [java]    at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:279)
     [java]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:263)
     [java]    at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:168)
     [java]    at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
     [java]    at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
     [java]    at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1027)
     [java]    at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:365)
     [java]    at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)


Can this consider a hibernate standard bug?

This issue is frustrating, been working on this stupid problem for 2 days, continuous testing and fixing and retesting ... (it goes on and on)
Is there any best practice to do couple of insert/update (which utilized few shared tables, erm ... assuming it's sequence of update is logical) in the same function?

[Additional Information]
Code:
=== HOST INFORMATION ===
Name:    localhost
Host:    localhost:3306
Server:  MySQL
Version: 5.1.49-1ubuntu8.1
User:    root

=== HIBERNATE VERSION ===
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: steve
Build-Jdk: 1.5.0_15
Specification-Title: Hibernate Core
Specification-Version: 3.3.0.SP1
Specification-Vendor: Hibernate.org
Implementation-Title: Hibernate Core
Implementation-Version: 3.3.0.SP1
Implementation-Vendor-Id: org.hibernate
Implementation-Vendor: Hibernate.org
Implementation-URL: http://hibernate.org/hibernate-core


Regards,
Avatar Ng


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.