org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

Atlassian JIRA | Donna McGahan [Atlassian] | 9 years ago
  1. 0

    Seeing fun stuff like this in the logs: {code} 22:08:02,222 ERROR org.codehaus.xfire.handler.DefaultFaultHandler: Fault occurred! org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not delete: [com.atlassian.crowd.integration.model.RemotePrincipal#component[directoryID,name]{directoryID=65537, name=novygees}]; SQL [delete from `REMOTEPRINCIPAL` where `DIRECTORYID`=? and `NAME`=?]; Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)); nested exception is java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)) java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)) {code} This may be a result of using MySQLInnoDB as mentioned in the [MySQL docs|http://dev.mysql.com/doc/refman/5.0/en/update.html]: _If you use a multiple-table UPDATE statement involving InnoDB tables for which there are foreign key constraints, the MySQL optimizer might process tables in an order that differs from that of their parent/child relationship. In this case, the statement fails and rolls back. Instead, update a single table and rely on the ON UPDATE capabilities that InnoDB provides to cause the other tables to be modified accordingly. See Section 12.2.6.4, "FOREIGN KEY Constraints"_ _Currently, you cannot update a table and select from the same table in a subquery._ {code} 10:03:49,351 ERROR org.hibernate.event.def.AbstractFlushingEventListener: 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 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2520) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697) at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74) 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:146) 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.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:811) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:809) at com.atlassian.crowd.util.persistence.hibernate.HibernateDao.remove(HibernateDao.java:53) at com.atlassian.crowd.model.principal.PrincipalDAOHibernate.remove(PrincipalDAOHibernate.java:200) at com.atlassian.crowd.integration.directory.internal.InternalDirectory.removePrincipal(InternalDirectory.java:659) at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.removePrincipal(DirectoryManagerGeneric.java:726) at sun.reflect.GeneratedMethodAccessor377.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.refl {code}

    Atlassian JIRA | 9 years ago | Donna McGahan [Atlassian]
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
  2. 0

    Seeing fun stuff like this in the logs: {code} 22:08:02,222 ERROR org.codehaus.xfire.handler.DefaultFaultHandler: Fault occurred! org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not delete: [com.atlassian.crowd.integration.model.RemotePrincipal#component[directoryID,name]{directoryID=65537, name=novygees}]; SQL [delete from `REMOTEPRINCIPAL` where `DIRECTORYID`=? and `NAME`=?]; Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)); nested exception is java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)) java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`crowddb/REMOTEGROUPMEMBERS`, CONSTRAINT `FKF8D0F100F19C38AE` FOREIGN KEY (`REMOTEPRINCIPALDIRECTORYID`, `REMOTEPRINCIPALNAME`) REFERENCES `REMOTEPRINCIPAL` (`DIRECTORYID`, `NAME`)) {code} This may be a result of using MySQLInnoDB as mentioned in the [MySQL docs|http://dev.mysql.com/doc/refman/5.0/en/update.html]: _If you use a multiple-table UPDATE statement involving InnoDB tables for which there are foreign key constraints, the MySQL optimizer might process tables in an order that differs from that of their parent/child relationship. In this case, the statement fails and rolls back. Instead, update a single table and rely on the ON UPDATE capabilities that InnoDB provides to cause the other tables to be modified accordingly. See Section 12.2.6.4, "FOREIGN KEY Constraints"_ _Currently, you cannot update a table and select from the same table in a subquery._ {code} 10:03:49,351 ERROR org.hibernate.event.def.AbstractFlushingEventListener: 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 at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61) at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2520) at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697) at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74) 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:146) 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.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:811) at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372) at org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:809) at com.atlassian.crowd.util.persistence.hibernate.HibernateDao.remove(HibernateDao.java:53) at com.atlassian.crowd.model.principal.PrincipalDAOHibernate.remove(PrincipalDAOHibernate.java:200) at com.atlassian.crowd.integration.directory.internal.InternalDirectory.removePrincipal(InternalDirectory.java:659) at com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.removePrincipal(DirectoryManagerGeneric.java:726) at sun.reflect.GeneratedMethodAccessor377.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.refl {code}

    Atlassian JIRA | 9 years ago | Donna McGahan [Atlassian]
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
  3. 0

    [Spacewalk-list] spacewalk-repo-sync is not generating any repodata.

    redhat.com | 1 year ago
    org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Spacewalk sends HibernateRuntimeException emails

    https://bugzilla.redhat.com/bugzilla/ | 7 years ago | Erik Logtenberg
    com.redhat.rhn.common.hibernate.HibernateRuntimeException: HibernateException executing CachedStatement
  6. 0

    Exceptions when a channel is empty

    https://bugzilla.redhat.com/bugzilla/ | 7 years ago | Mark Chappell
    com.redhat.rhn.common.hibernate.HibernateRuntimeException: HibernateException executing CachedStatement

  1. mauritius 2 times, last 3 months ago
2 unregistered visitors
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. org.hibernate.StaleStateException

    Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

    at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched()
  2. Hibernate
    AbstractEntityPersister.delete
    1. org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
    2. org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
    3. org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24)
    4. org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2520)
    5. org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2697)
    5 frames
  3. Hibernate
    EntityDeleteAction.execute
    1. org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:74)
    1 frame
  4. Hibernate
    ActionQueue.executeActions
    1. org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
    2. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
    3. org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:146)
    3 frames
  5. Hibernate
    SessionImpl.flush
    1. org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
    2. org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
    3. org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
    3 frames
  6. Hibernate
    HibernateTemplate.flush
    1. org.springframework.orm.hibernate3.HibernateTemplate$27.doInHibernate(HibernateTemplate.java:811)
    2. org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:372)
    3. org.springframework.orm.hibernate3.HibernateTemplate.flush(HibernateTemplate.java:809)
    3 frames
  7. com.atlassian.crowd
    DirectoryManagerGeneric.removePrincipal
    1. com.atlassian.crowd.util.persistence.hibernate.HibernateDao.remove(HibernateDao.java:53)
    2. com.atlassian.crowd.model.principal.PrincipalDAOHibernate.remove(PrincipalDAOHibernate.java:200)
    3. com.atlassian.crowd.integration.directory.internal.InternalDirectory.removePrincipal(InternalDirectory.java:659)
    4. com.atlassian.crowd.manager.directory.DirectoryManagerGeneric.removePrincipal(DirectoryManagerGeneric.java:726)
    4 frames
  8. Java RT
    DelegatingMethodAccessorImpl.invoke
    1. sun.reflect.GeneratedMethodAccessor377.invoke(Unknown Source)
    2. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    2 frames