-->
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.  [ 4 posts ] 
Author Message
 Post subject: Newbie Persistince Problems: Batch update returned unexpecte
PostPosted: Tue May 10, 2005 12:29 pm 
Newbie

Joined: Tue Jul 13, 2004 11:51 am
Posts: 13
Hi, ... I am new to hibernate and need to get this simple relationship persisted :-(((

please see below ..


Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.x, jboss 4.0.2
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
see below

Name and version of the database you are using:
MySQL

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:



Hi can someone please please help me wth this error :-( I can't seem to save this object and on top of that the transaction breaks as part of the data is persisted.

We have a User who has man UserProperties

When this fails, the user is still in the DB and never gets rolled back, . .. any ideas why UserProperties is never stored ?

Please help anyone :-((



2005-05-09 19:12:19,797 DEBUG [org.jboss.deployment.MainDeployer] End deployment start on package: freematchmaker.ear
2005-05-09 19:12:19,798 DEBUG [org.jboss.deployment.MainDeployer] Deployed package: file:/home/james/projects/engine/prod/jboss/jboss-4.0.2/server/default/deploy/freematchmaker.ear
2005-05-09 19:13:01,432 DEBUG [proxy.UserManagerBean] Creating User - [ User:
username=james0
password=bling
]
2005-05-09 19:13:01,440 DEBUG [engine.util.hibernate.HibernateUtil] Starting new database transaction in this thread.
2005-05-09 19:13:01,443 DEBUG [engine.util.hibernate.HibernateUtil] Opening new Session for this thread.
2005-05-09 19:13:01,445 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] JNDI lookup: hibernate/EngineSessionFactory
2005-05-09 19:13:01,445 DEBUG [org.hibernate.impl.SessionFactoryObjectFactory] lookup: uid=ff80808103c28eab0103c2a848a00002
2005-05-09 19:13:01,445 DEBUG [org.hibernate.jdbc.JDBCContext] successfully registered Synchronization
2005-05-09 19:13:01,445 DEBUG [org.hibernate.impl.SessionImpl] opened session at timestamp: 4569753114398720
2005-05-09 19:13:01,445 DEBUG [org.hibernate.transaction.JTATransaction] begin
2005-05-09 19:13:01,445 DEBUG [org.hibernate.transaction.JTATransaction] Looking for UserTransaction under: UserTransaction
2005-05-09 19:13:01,446 DEBUG [org.hibernate.transaction.JTATransaction] Obtained UserTransaction
2005-05-09 19:13:01,448 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] transient instance of: engine.model.User
2005-05-09 19:13:01,448 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] saving transient instance
2005-05-09 19:13:01,449 DEBUG [org.hibernate.engine.TransactionHelper] surrounding tx suspended
2005-05-09 19:13:01,449 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-05-09 19:13:01,450 DEBUG [org.hibernate.SQL] select next_hi from hibernate_unique_key for update
2005-05-09 19:13:01,451 DEBUG [org.hibernate.SQL] update hibernate_unique_key set next_hi = ? where next_hi = ?
2005-05-09 19:13:01,453 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
2005-05-09 19:13:01,453 DEBUG [org.hibernate.engine.TransactionHelper] surrounding tx resumed
2005-05-09 19:13:01,453 DEBUG [org.hibernate.id.TableHiLoGenerator] new hi value: 0
2005-05-09 19:13:01,453 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] generated identifier: 1, using strategy: org.hibernate.id.TableHiLoGenerator
2005-05-09 19:13:01,454 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] saving [engine.model.User#1]
2005-05-09 19:13:01,454 DEBUG [org.hibernate.engine.Cascades] processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,454 DEBUG [org.hibernate.engine.Cascades] done processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,455 DEBUG [org.hibernate.event.def.WrapVisitor] Wrapped collection in role: engine.model.User.userProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] cascade ACTION_SAVE_UPDATE for collection: engine.model.User.userProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] cascading to saveOrUpdate: engine.model.UserProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] id unsaved-value strategy NULL
2005-05-09 19:13:01,455 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] detached instance of: engine.model.UserProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating detached instance
2005-05-09 19:13:01,455 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [engine.model.UserProperties#locale]
2005-05-09 19:13:01,455 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] updating [engine.model.UserProperties#locale]
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] done cascade ACTION_SAVE_UPDATE for collection: engine.model.User.userProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] deleting orphans for collection: engine.model.User.userProperties
2005-05-09 19:13:01,455 DEBUG [org.hibernate.engine.Cascades] done deleting orphans for collection: engine.model.User.userProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] done processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,456 INFO [proxy.UserManagerBean] Created New User. james0
2005-05-09 19:13:01,456 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction before completion callback
2005-05-09 19:13:01,456 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically flushing session
2005-05-09 19:13:01,456 DEBUG [org.hibernate.impl.SessionImpl] automatically flushing session
2005-05-09 19:13:01,456 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] flushing session
2005-05-09 19:13:01,456 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] processing flush-time cascades
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] cascade ACTION_SAVE_UPDATE for collection: engine.model.User.userProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] cascading to saveOrUpdate: engine.model.UserProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.event.def.AbstractSaveEventListener] persistent instance of: engine.model.UserProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] ignoring persistent instance
2005-05-09 19:13:01,456 DEBUG [org.hibernate.event.def.DefaultSaveOrUpdateEventListener] object already associated with session: [engine.model.UserProperties#locale]
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] done cascade ACTION_SAVE_UPDATE for collection: engine.model.User.userProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] deleting orphans for collection: engine.model.User.userProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] done deleting orphans for collection: engine.model.User.userProperties
2005-05-09 19:13:01,456 DEBUG [org.hibernate.engine.Cascades] done processing cascade ACTION_SAVE_UPDATE for: engine.model.User
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] dirty checking collections
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushing entities and processing referenced collections
2005-05-09 19:13:01,457 DEBUG [org.hibernate.engine.Collections] Collection found: [engine.model.User.userProperties#1], was: [<unreferenced>] (initialized)
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.DefaultFlushEntityEventListener] Updating entity: [engine.model.UserProperties#locale]
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Processing unreferenced collections
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Scheduling collection removes/(re)creates/updates
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 1 insertions, 1 updates, 0 deletions to 2 objects
2005-05-09 19:13:01,457 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] Flushed: 1 (re)creations, 0 updates, 0 removals to 1 collections
2005-05-09 19:13:01,457 DEBUG [org.hibernate.pretty.Printer] listing entities:
2005-05-09 19:13:01,457 DEBUG [org.hibernate.pretty.Printer] engine.model.UserProperties{value=uk, name=locale}
2005-05-09 19:13:01,509 DEBUG [org.hibernate.pretty.Printer] engine.model.User{active=true, password=bling, userName=james0, userProperties=[engine.model.UserProperties#locale], userId=1, registrationDate=2005-05-09 19:13:01, email=crap@com.uk, lastLoginDate=2005-05-09 19:13:01}
2005-05-09 19:13:01,509 DEBUG [org.hibernate.event.def.AbstractFlushingEventListener] executing flush
2005-05-09 19:13:01,509 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Inserting entity: [engine.model.User#1]
2005-05-09 19:13:01,509 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-05-09 19:13:01,509 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-05-09 19:13:01,510 DEBUG [org.hibernate.SQL] insert into USER (USERNAME, PASSWORD, EMAIL, REG_DATE, LAST_LOGIN, ACTIVE, USER_ID) values (?, ?, ?, ?, ?, ?, ?)
2005-05-09 19:13:01,511 INFO [STDOUT] Hibernate: insert into USER (USERNAME, PASSWORD, EMAIL, REG_DATE, LAST_LOGIN, ACTIVE, USER_ID) values (?, ?, ?, ?, ?, ?, ?)
2005-05-09 19:13:01,511 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-05-09 19:13:01,511 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Dehydrating entity: [engine.model.User#1]
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.StringType] binding 'james0' to parameter: 1
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.StringType] binding 'bling' to parameter: 2
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.StringType] binding 'crap@com.uk' to parameter: 3
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.TimestampType] binding '2005-05-09 19:13:01' to parameter: 4
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.TimestampType] binding '2005-05-09 19:13:01' to parameter: 5
2005-05-09 19:13:01,512 DEBUG [org.hibernate.type.BooleanType] binding 'true' to parameter: 6
2005-05-09 19:13:01,513 DEBUG [org.hibernate.type.LongType] binding '1' to parameter: 7
2005-05-09 19:13:01,513 DEBUG [org.hibernate.jdbc.AbstractBatcher] Adding to batch
2005-05-09 19:13:01,513 DEBUG [org.hibernate.jdbc.AbstractBatcher] Executing batch size: 1
2005-05-09 19:13:01,518 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-05-09 19:13:01,518 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-05-09 19:13:01,518 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
2005-05-09 19:13:01,518 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Updating entity: [engine.model.UserProperties#locale]
2005-05-09 19:13:01,518 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to open PreparedStatement (open PreparedStatements: 0, globally: 0)
2005-05-09 19:13:01,518 DEBUG [org.hibernate.jdbc.AbstractBatcher] opening JDBC connection
2005-05-09 19:13:01,518 DEBUG [org.hibernate.SQL] update USERPROPERTIES set PROPERTYVALUE=? where PROPERTYNAME=?
2005-05-09 19:13:01,519 INFO [STDOUT] Hibernate: update USERPROPERTIES set PROPERTYVALUE=? where PROPERTYNAME=?
2005-05-09 19:13:01,519 DEBUG [org.hibernate.jdbc.AbstractBatcher] preparing statement
2005-05-09 19:13:01,522 DEBUG [org.hibernate.persister.entity.BasicEntityPersister] Dehydrating entity: [engine.model.UserProperties#locale]
2005-05-09 19:13:01,522 DEBUG [org.hibernate.type.StringType] binding 'uk' to parameter: 1
2005-05-09 19:13:01,522 DEBUG [org.hibernate.type.StringType] binding 'locale' to parameter: 2
2005-05-09 19:13:01,522 DEBUG [org.hibernate.jdbc.AbstractBatcher] Adding to batch
2005-05-09 19:13:01,522 DEBUG [org.hibernate.jdbc.AbstractBatcher] Executing batch size: 1
2005-05-09 19:13:01,524 ERROR [org.hibernate.jdbc.AbstractBatcher] 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.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:716)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:310)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:58)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1384)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1076)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:296)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:486)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:346)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
2005-05-09 19:13:01,525 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2005-05-09 19:13:01,526 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing statement
2005-05-09 19:13:01,526 DEBUG [org.hibernate.jdbc.AbstractBatcher] closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)
2005-05-09 19:13:01,526 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.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:716)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:310)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:58)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1384)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1076)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:296)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:486)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:346)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
2005-05-09 19:13:01,527 DEBUG [org.hibernate.jdbc.JDBCContext] before transaction completion
2005-05-09 19:13:01,527 DEBUG [org.hibernate.impl.SessionImpl] before transaction completion
2005-05-09 19:13:01,529 DEBUG [org.hibernate.transaction.CacheSynchronization] transaction after completion callback, status: 4
2005-05-09 19:13:01,529 DEBUG [org.hibernate.jdbc.JDBCContext] after transaction completion
2005-05-09 19:13:01,529 DEBUG [org.hibernate.impl.SessionImpl] after transaction completion
2005-05-09 19:13:01,529 DEBUG [org.hibernate.transaction.CacheSynchronization] automatically closing session
2005-05-09 19:13:01,529 DEBUG [org.hibernate.impl.SessionImpl] automatically closing session
2005-05-09 19:13:01,529 DEBUG [org.hibernate.impl.SessionImpl] closing session
2005-05-09 19:13:01,530 ERROR [org.jboss.ejb.plugins.LogInterceptor] TransactionRolledbackException in method: public abstract void proxy.UserManager.create(engine.model.User) throws java.rmi.RemoteException, causedBy:
org.jboss.tm.JBossRollbackException: Unable to commit, tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=saturn/18, BranchQual=, localId=18] status=STATUS_NO_TRANSACTION; - nested throwable: (org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:344)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:486)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:346)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:644)
at org.jboss.invocation.jrmp.server.JRMPInvoker$MBeanServerAction.invoke(JRMPInvoker.java:805)
at org.jboss.invocation.jrmp.server.JRMPInvoker.invoke(JRMPInvoker.java:406)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:294)
at sun.rmi.transport.Transport$1.run(Transport.java:153)
at sun.rmi.transport.Transport.serviceCall(Transport.java:149)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:460)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:701)
at java.lang.Thread.run()V(Unknown Source)
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:716)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:310)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:58)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1384)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1076)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:296)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:486)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:346)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
2005-05-09 19:13:19,176 DEBUG [org.hibernate.jdbc.JDBCContext] running Session.finalize()


/**
* @hibernate.class table="USER"
*/
public class User implements Serializable {

private Long userId = null;
private String userName = null;
private String password = null;
private String email = null;
private Date registrationDate = null;
private Date lastLoginDate = null;
private boolean active = false;
private Set userProperties = null;

public User() {
userProperties = new HashSet();
}



/**
* @hibernate.id column="USER_ID"
* not-null="true"
* generator-class="hilo"
* update="false"
* unique="true"
*/
public Long getUserId() {
return userId;
}
public void setUserId(Long id) {
this.userId = id;
}

/**
* @hibernate.property column="USERNAME"
* not-null="true"
* generator-class="assigned"
* update="false"
*/
public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

/**
* @hibernate.property column="PASSWORD"
* not-null="true"
* update="true"
*/
public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

/**
* @hibernate.property column="EMAIL"
* not-null="true"
* update="true"
* unique="true"
*/
public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

/**
* @hibernate.property column="REG_DATE"
* not-null="true"
* update="false"
*/
public Date getRegistrationDate() {
return registrationDate;
}

public void setRegistrationDate(Date registrationDate) {
this.registrationDate = registrationDate;
}

/**
* @hibernate.property column="LAST_LOGIN"
* not-null="true"
* update="true"
*/
public Date getLastLoginDate() {
return lastLoginDate;
}

public void setLastLoginDate(Date lastLoginDate) {
this.lastLoginDate = lastLoginDate;
}

/**
* @hibernate.property column="ACTIVE"
* not-null="true"
* update="true"
*/
public boolean isActive() {
return active;
}

public void setActive(boolean active) {
this.active = active;
}


/**
* @hibernate.set lazy="false"
* inverse="true"
* cascade="all-delete-orphan"
* @hibernate.collection-key column="USER_ID" not-null="true"
* @hibernate.collection-one-to-many class="engine.model.UserProperties"
*/

public Set getUserProperties() {
return userProperties;
}

public void setUserProperties(Set userProperties) {
this.userProperties = userProperties;
}


public void setProperty(String name, String value) {
UserProperties prop = new UserProperties();
prop.setName(name);
prop.setValue(value);
userProperties.add(prop);
}

public String getProperty(String name) {
Iterator it = userProperties.iterator();
while(it.hasNext()){
UserProperties prop = (UserProperties)it.next();
if(prop.getName().equalsIgnoreCase(name)){
return prop.getValue();
}
}
return "";

}


public void addUserProperty(UserProperties prop) {
this.userProperties.add(prop);
}

public void removeUserProperty(UserProperties prop) {
this.userProperties.remove(prop);
}



public String toString() {
StringBuffer buf = new StringBuffer();
buf.append("[ User: ").append("\n");
buf.append("\t username=").append(this.userName).append("\n");
buf.append("\t password=").append(this.password).append("\n");
buf.append(" ]");
return buf.toString();
}

}


/**
* @hibernate.class table="USERPROPERTIES"
*/
public class UserProperties implements Serializable {


private String name = null;
private String value = null;

/**
* @hibernate.id column="PROPERTYNAME"
* not-null="true"
* generator-class="assigned"
* update="false"
* unsaved-value="null"
*/
public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

/**
* @hibernate.property column="PROPERTYVALUE"
* not-null="true"
* update="true"
* unsaved-value="null"
*/
public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}


}

I am using some code from caveat empto: but esseentially, here are the wapping code:

From Sesion bean

/**
* @ejb.interface-method viewtype="remote"
*/
public void create(User user) throws RemoteException {
if(log.isDebugEnabled()) {
log.debug("Creating User - " + user);
}

UserDAO userDAO = new UserDAO();
userDAO.makePersistent(user);
log.info("Created New User. " + user.getUserName());

}


From DAO:

public class UserDAO {

public UserDAO() {
HibernateUtil.beginTransaction();
}


public void makePersistent(User user)
throws DAOException {

try {
HibernateUtil.getSession().saveOrUpdate(user);
} catch (HibernateException ex) {
throw new DAOException(ex);
}
}

Please helping me..... :-(


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 1:14 pm 
Regular
Regular

Joined: Mon Jul 26, 2004 2:28 pm
Posts: 86
Location: Pensacola, Florida
Use Session.save( ) instead of Session.saveOrUpdate( ). When you use the "assigned" generator class you must use Session.save( ) or Session.update( ) explictly. If you use Session.saveOrUpdate( ), Hibernate doesn't know whether to perform an INSERT or an UPDATE and selects the latter by default (presumably because you have an unsaved-value of null, and your ID is not null).

If you absolutely must use Session.saveOrUpdate( ), then implement Interceptor and provide the logic in the isUnsaved( ) method.

- Jesse


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 1:52 pm 
Newbie

Joined: Tue Jul 13, 2004 11:51 am
Posts: 13
Hi Jesse

I tried that and it still failed with the same exception. This is my first persistence attempt using hibernate and i can't beleive that its so hard to persist a simple relatoinship :-( I must be really dumb :-(((

org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:92)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:78)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:716)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:310)
at org.hibernate.transaction.CacheSynchronization.beforeCompletion(CacheSynchronization.java:58)
at org.jboss.tm.TransactionImpl.doBeforeCompletion(TransactionImpl.java:1384)
at org.jboss.tm.TransactionImpl.beforePrepare(TransactionImpl.java:1076)
at org.jboss.tm.TransactionImpl.commit(TransactionImpl.java:296)
at org.jboss.ejb.plugins.TxInterceptorCMT.endTransaction(TxInterceptorCMT.java:486)
at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:346)
at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:139)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:873)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:141)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
2005-05-10 18:43:15,749 DEBUG [org.hibernate.jdbc.AbstractBatcher] about to close PreparedStatement (open PreparedStatements: 1, globally: 1)


ie .. the same exception. Are my xdockelt tags ok ? I have attached the generated mapping files, ..

### User ####

<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="engine.model.User"
table="USER"
>

<id
name="userId"
column="USER_ID"
type="java.lang.Long"
>
<generator class="hilo">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-User.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="userName"
type="java.lang.String"
update="false"
insert="true"
column="USERNAME"
not-null="true"
/>

<property
name="password"
type="java.lang.String"
update="true"
insert="true"
column="PASSWORD"
not-null="true"
/>

<property
name="email"
type="java.lang.String"
update="true"
insert="true"
column="EMAIL"
not-null="true"
unique="true"
/>

<property
name="registrationDate"
type="java.util.Date"
update="false"
insert="true"
column="REG_DATE"
not-null="true"
/>

<property
name="lastLoginDate"
type="java.util.Date"
update="true"
insert="true"
column="LAST_LOGIN"
not-null="true"
/>

<property
name="active"
type="boolean"
update="true"
insert="true"
column="ACTIVE"
not-null="true"
/>

<set
name="userProperties"
lazy="false"
inverse="true"
cascade="all-delete-orphan"
sort="unsorted"
>

<key
column="USER_ID"
>
</key>

<one-to-many
class="engine.model.UserProperties"
/>

</set>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-User.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


## User Properties ####

<?xml version="1.0" encoding="UTF-8"?>

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

<hibernate-mapping
>
<class
name="engine.model.UserProperties"
table="USERPROPERTIES"
>

<id
name="name"
column="PROPERTYNAME"
type="java.lang.String"
unsaved-value="null"
>
<generator class="assigned">
<!--
To add non XDoclet generator parameters, create a file named
hibernate-generator-params-UserProperties.xml
containing the additional parameters and place it in your merge dir.
-->
</generator>
</id>

<property
name="value"
type="java.lang.String"
update="true"
insert="true"
column="PROPERTYVALUE"
not-null="true"
/>

<!--
To add non XDoclet property mappings, create a file named
hibernate-properties-UserProperties.xml
containing the additional properties and place it in your merge dir.
-->

</class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 10, 2005 5:10 pm 
Regular
Regular

Joined: Mon Oct 06, 2003 7:17 am
Posts: 58
Location: Switzerland
You have to remove the unsaved-value="null" when you call explicitly session.save() when you save or session.update() if you update the UserProperties with an assigned id. When you still want to call session.saveOrUpdate() you can add a version column in the mapping file

Code:
<class
name="engine.model.UserProperties"
table="USERPROPERTIES"
>
<version name="version"
column="VERSION"
unsaved-value="0"/>

.......



Reto[/quote]


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