-->
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.  [ 3 posts ] 
Author Message
 Post subject: why :( :( .When call to saveOrUpdate it delete obj before
PostPosted: Wed Dec 20, 2006 3:02 pm 
Newbie

Joined: Wed Dec 20, 2006 2:41 pm
Posts: 3
insert.

I am going to cry.
I dont know what to do with this.

i have A with many to one with B . cascade is all

B has many to many (idbag)with C.
B and C PK is assigned by the application

A_DAO::
Code:
      Session session = TransactionManager.getConnection();
      session.saveOrUpdate(queryEvent);
      TransactionManager.close(true);


in case of failure - rollback.
session is on threadlocal

when i call to single thread that send a lot of A with the same B (B exists in the DB)
it is ok.

but when i run multi threads that send a lot of A with the same B
hibernate after some time try to delete B before insert (why, why,why).

This cause to this exception:
Code:
org.hibernate.exception.LockAcquisitionException: could not delete collection: [com.mercado.s2002.analysis.objects.CriteriaDictionary.Criterion#-231454997]

....
Caused by: org.hibernate.exception.LockAcquisitionException: could not delete collection: [com.mercado.s2002.analysis.objects.CriteriaDictionary.Criterion#-231454997]
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1023)
   at org.hibernate.action.CollectionRemoveAction.execute(CollectionRemoveAction.java:28)
   at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
   at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
   at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:993)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:340)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
   at com.mercado.s2002.analysis.util.TransactionManager.commit(TransactionManager.java:230)
   at com.mercado.s2002.analysis.util.TransactionManager.close(TransactionManager.java:370)
   at com.mercado.s2002.analysis.dao.hibernate.QueryEventDAO.save(QueryEventDAO.java:59)
   ... 38 more
Caused by: java.sql.SQLException: Deadlock found when trying to get lock; try restarting transaction
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
   at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1124)
   at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:676)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1166)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1082)
   at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1067)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)
   at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
   at org.hibernate.persister.collection.AbstractCollectionPersister.remove(AbstractCollectionPersister.java:1011)
   ... 50 more


when i try to save again. i get:
Code:
org.hibernate.StaleStateException: Unexpected row count: 0 expected: 1


Please advice.


Top
 Profile  
 
 Post subject: I have a clue ,but still far away from soultion
PostPosted: Wed Dec 20, 2006 3:54 pm 
Newbie

Joined: Wed Dec 20, 2006 2:41 pm
Posts: 3
when i tried to save only B, although B exists in the DB it first delete B_TO_C records and than insert them again.

I dont want to do this.

B is group of students (C)

if B exists there is no need to recreate the realtion between B_TO_C

B cannot change .

B PK is calculate according to the students name that B contain, so there is no need to update .


Top
 Profile  
 
 Post subject: Deadlock DB2 while no need to update
PostPosted: Mon Oct 06, 2008 12:26 pm 
Newbie

Joined: Tue Jun 15, 2004 11:44 am
Posts: 7
Description of this issue is exactly matching what it occurs in my case for DB2 UDB 8.2 (8.1 with fixpak 17).

Hibernate version is: 3.3.1.GA (but same result with 3.2.5.GA).

An object Claim contains a list of several items:

<list lazy="true" cascade="all" name="items">
<key foreign-key="ITEM_CLAIMID_FK" column="CBK_CLAIMID"/>
<list-index column="SEQUENCE"/>
<one-to-many class="be.eft.cbkv3.data.schema.Item"/>
</list>

Everything is fine in single thread but for an unexplained reason I run into a deadlock while running in multi-threads environment:

Thread-1 is performing:
>>update CBK_ITEM set CBK_CLAIMID=null, SEQUENCE=null where CBK_CLAIMID=?
>> binding '2035251' to parameter: 1

Thread-2 is performing:
>>update CBK_ITEM set CBK_CLAIMID=null, SEQUENCE=null where CBK_CLAIMID=?
>> binding '2035252' to parameter: 1

Any help would be greatly appreciated.


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