2 Replies Latest reply on Aug 13, 2007 12:02 PM by Fan Mou

    Hibernate Exception

    Fan Mou Newbie

      Hi.
      I have this problem for a long time and can not solve it.
      Does anyone know, what may be the reason and solution of the exception:

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

      Thanks!

        • 1. Re: Hibernate Exception
          Fernando Montaño Expert

          How your JPA QL for batch update looks like? (post code)

          • 2. Re: Hibernate Exception
            Fan Mou Newbie

            I have the following classes:
            class Item, class AnnotationArea.
            Item(long id;String title;URL link;String language;Date date;String description;String article;ing guidTag;Set annotationArea)

            AnnotationArea(long annotationId, long startoffset, long startendset, String annotationSetName, Map<String, String> features)

            Mapping file:

            Item.hbm.xml
            <?xml version="1.0"?>
            <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
            <hibernate-mapping>













            <many-to-many column="EMMTRIGGER_ID" class="dataObjects.EmmTrigger"/>


            <key column="ITEM_ID" not-null="true"/>
            <many-to-many column="ANNOTATION_ID" class="dataObjects.AnnotationArea" unique="true"/>


            </hibernate-mapping>
            AnnotationArea.hbm.xml

            <?xml version="1.0"?>
            <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
            <hibernate-mapping>







            <map name="features" table="FEATURES" order-by="feature_name asc">

            <map-key column="feature_name" type="string"/>
            <element type="string" column="feature_value" not-null="false"/>


            </hibernate-mapping>

            The problem occurs, when I want to update the annotationArea.
            I use GATE and HSQL datastore.
            Error:

            Using C:\Program Files\GATE-4.0 as GATE home
            Using C:\Program Files\GATE-4.0\plugins as installed plug-ins directory.
            Using C:\Program Files\GATE-4.0\gate.xml as site configuration file.
            Using C:\Documents and Settings\Administrator\gate.xml as user configuration file
            Using C:\Documents and Settings\Administrator\gate.session as user session file
            CREOLE plugin loaded: file:/C:/Program Files/GATE-3.1/plugins/ANNIE/
            17:59:31,203 INFO UpdateDatabase:50 - initiate GATE!
            17:59:31,265 INFO UpdateDatabase:62 - serialdatastore is opened.
            17:59:31,281 INFO UpdateDatabase:68 - get all document ids..
            17:59:31,281 INFO UpdateDatabase:70 - the first document id: 17507___1186991906296___6100
            17:59:31,390 INFO UpdateDatabase:123 - document_id: 17507
            17:59:31,390 INFO UpdateDatabase:95 - without annotation Id is 17507content This is a test article :-)guidTag nulldescription nullarticle This is a test article :-)
            17:59:31,390 INFO UpdateDatabase:166 - startoffset: 0
            17:59:31,390 INFO UpdateDatabase:167 - endoffset: 4
            17:59:31,390 INFO UpdateDatabase:169 - AnnotationTyp: feature1
            17:59:31,390 INFO UpdateDatabase:171 - feature: {1id=1234}
            17:59:31,390 INFO UpdateDatabase:173 - annotationId: 1
            17:59:31,406 INFO UpdateDatabase:176 - AnnotationArea:
            id: 1
            annotationNameSet: feature1
            startOffset: 0
            endOffset: 4
            features{1id=1234}
            17:59:31,406 INFO UpdateDatabase:179 - with annotation [AnnotationArea:
            id: 1
            annotationNameSet: feature1
            startOffset: 0
            endOffset: 4
            features{1id=1234}]
            17:59:31,406 INFO UpdateDatabase:97 - Item final id 17507
            17:59:31,546 INFO Environment:500 - Hibernate 3.2.0.cr5
            17:59:31,562 INFO Environment:533 - hibernate.properties not found
            17:59:31,562 INFO Environment:667 - Bytecode provider name : cglib
            17:59:31,578 INFO Environment:584 - using JDK 1.4 java.sql.Timestamp handling
            17:59:31,765 INFO Configuration:1350 - configuring from resource: /hibernate.cfg.xml
            17:59:31,765 INFO Configuration:1327 - Configuration resource: /hibernate.cfg.xml
            17:59:31,937 INFO Configuration:507 - Reading mappings from resource: dataObjects/Item.hbm.xml
            17:59:32,171 INFO HbmBinder:300 - Mapping class: dataObjects.Item -> ITEMS
            17:59:32,265 INFO HbmBinder:1412 - Mapping collection: dataObjects.Item.emmTriggers -> ITEM_EMMTRIGGER
            17:59:32,265 INFO HbmBinder:1412 - Mapping collection: dataObjects.Item.annotationArea -> ITEM_ANNOTATION
            17:59:32,265 INFO Configuration:507 - Reading mappings from resource: dataObjects/EmmTrigger.hbm.xml
            17:59:32,343 INFO HbmBinder:300 - Mapping class: dataObjects.EmmTrigger -> EMMTRIGGER
            17:59:32,343 INFO Configuration:507 - Reading mappings from resource: dataObjects/AnnotationArea.hbm.xml
            17:59:32,421 INFO HbmBinder:300 - Mapping class: dataObjects.AnnotationArea -> ANNOTATIONAREA
            17:59:32,421 INFO HbmBinder:1412 - Mapping collection: dataObjects.AnnotationArea.features -> FEATURES
            17:59:32,421 INFO Configuration:1465 - Configured SessionFactory: null
            17:59:32,625 INFO C3P0ConnectionProvider:50 - C3P0 using driver: org.hsqldb.jdbcDriver at URL: jdbc:hsqldb:hsql://localhost
            17:59:32,625 INFO C3P0ConnectionProvider:51 - Connection properties: {user=sa, password=****}
            17:59:32,625 INFO C3P0ConnectionProvider:54 - autocommit mode: false
            17:59:32,703 INFO MLog:80 - MLog clients using log4j logging.
            17:59:33,953 INFO C3P0Registry:204 - Initializing c3p0-0.9.1.1 [built 15-March-2007 01:32:31; debug? true; trace: 10]
            17:59:34,187 INFO AbstractPoolBackedDataSource:462 - Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@c786ab36 [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@bfb659b9 [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 1hge1367oqmfkzf1veg14g|1976011, idleConnectionTestPeriod -> 3000, initialPoolSize -> 5, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 300, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 20, maxStatements -> 50, maxStatementsPerConnection -> 0, minPoolSize -> 5, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@7a149228 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 1hge1367oqmfkzf1veg14g|1b15692, jdbcUrl -> jdbc:hsqldb:hsql://localhost, properties -> {user=******, password=******} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 1hge1367oqmfkzf1veg14g|13c6a22, numHelperThreads -> 3 ]
            17:59:34,703 INFO SettingsFactory:81 - RDBMS: HSQL Database Engine, version: 1.8.0
            17:59:34,703 INFO SettingsFactory:82 - JDBC driver: HSQL Database Engine Driver, version: 1.8.0
            17:59:35,031 INFO Dialect:141 - Using dialect: org.hibernate.dialect.HSQLDialect
            17:59:35,125 INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
            17:59:35,125 INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
            17:59:35,125 INFO SettingsFactory:134 - Automatic flush during beforeCompletion(): disabled
            17:59:35,140 INFO SettingsFactory:138 - Automatic session close at end of transaction: disabled
            17:59:35,140 INFO SettingsFactory:145 - JDBC batch size: 15
            17:59:35,140 INFO SettingsFactory:148 - JDBC batch updates for versioned data: disabled
            17:59:35,140 INFO SettingsFactory:153 - Scrollable result sets: enabled
            17:59:35,140 INFO SettingsFactory:161 - JDBC3 getGeneratedKeys(): disabled
            17:59:35,140 INFO SettingsFactory:169 - Connection release mode: auto
            17:59:35,171 INFO SettingsFactory:196 - Default batch fetch size: 1
            17:59:35,171 INFO SettingsFactory:200 - Generate SQL with comments: disabled
            17:59:35,171 INFO SettingsFactory:204 - Order SQL updates by primary key: disabled
            17:59:35,171 INFO SettingsFactory:369 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
            17:59:35,187 INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
            17:59:35,203 INFO SettingsFactory:212 - Query language substitutions: {}
            17:59:35,218 INFO SettingsFactory:217 - JPA-QL strict compliance: disabled
            17:59:35,218 INFO SettingsFactory:222 - Second-level cache: enabled
            17:59:35,218 INFO SettingsFactory:226 - Query cache: disabled
            17:59:35,218 INFO SettingsFactory:356 - Cache provider: org.hibernate.cache.NoCacheProvider
            17:59:35,218 INFO SettingsFactory:241 - Optimize cache for minimal puts: disabled
            17:59:35,218 INFO SettingsFactory:250 - Structured second-level cache entries: disabled
            17:59:35,234 INFO SettingsFactory:270 - Echoing all SQL to stdout
            17:59:35,234 INFO SettingsFactory:277 - Statistics: disabled
            17:59:35,265 INFO SettingsFactory:281 - Deleted entity synthetic identifier rollback: disabled
            17:59:35,265 INFO SettingsFactory:296 - Default entity-mode: pojo
            17:59:35,437 INFO SessionFactoryImpl:161 - building session factory
            17:59:36,203 INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
            17:59:36,218 INFO HibernateUtil:28 - -SESSION---------------------------------------------------------
            17:59:36,218 INFO HibernateUtil:30 - -----------------------------------------------------------------
            17:59:36,421 WARN UpdateDatabase:136 - 17507
            Hibernate: insert into ITEMS (ITEM_ID, title, link, language, ITEM_DATE, description, article, guidTag) values (null, ?, ?, ?, ?, ?, ?, ?)
            Hibernate: call identity()
            Hibernate: update ANNOTATIONAREA set STARTOFFSET=?, ENDOFFSET=?, ANNOTATIONNAMESET=? where ANNOTATION_ID=?
            17:59:36,656 ERROR AbstractBatcher:51 - Exception executing batch:
            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.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
            at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
            at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
            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 theseus.fzi.de.main.UpdateDatabase.synchronize(UpdateDatabase.java:151)
            at theseus.fzi.de.main.UpdateDatabase.main(UpdateDatabase.java:98)
            17:59:36,656 ERROR AbstractFlushingEventListener:301 - 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.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
            at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
            at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
            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 theseus.fzi.de.main.UpdateDatabase.synchronize(UpdateDatabase.java:151)
            at theseus.fzi.de.main.UpdateDatabase.main(UpdateDatabase.java:98)
            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.BatchingBatcher.checkRowCounts(BatchingBatcher.java:68)
            at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:48)
            at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:242)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
            at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
            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 theseus.fzi.de.main.UpdateDatabase.synchronize(UpdateDatabase.java:151)
            at theseus.fzi.de.main.UpdateDatabase.main(UpdateDatabase.java:98)