-->
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: Hibernate and MS sQL server driver problem
PostPosted: Thu Mar 04, 2004 11:16 pm 
Newbie

Joined: Wed Aug 27, 2003 5:31 am
Posts: 10
Hi, Hibernate gurus
According to URL:http://www.hibernate.org/74.html#A13
there's a known problem of MS SQL Server driver(Microsoft's official driver) which fails to return correct
batch update number hibernate expected. So hibernate may throw stacktrace like:
Code:
net.sf.hibernate.HibernateException: Batch update row count wrong: 0
   at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:65)
   at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:118)
   at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:55)
   at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:105)
   at net.sf.hibernate.persister.EntityPersister.delete(EntityPersister.java:565)
   at net.sf.hibernate.impl.ScheduledDeletion.execute(ScheduledDeletion.java:29)
   at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2308)
   at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2266)
We use hibernate 2.1.1. This prolem still crop up.
Is there any patch addressing this issue?
And what's the consequence if so-called // check return codes section in
BatchingBatcher(Line 56-68) is removed.
See $Id: BatchingBatcher.java,v 1.4.2.6 2003/11/27 16:09:59 oneovthafew Exp $

Or can we change the check policy to make expected update count to 0 when underlying
driver is MS SQL Server by introducing a config parameter such as "ignore_batchupdate_bug"?

Regards,
Justin
2004-03-05 11:08


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 3:49 am 
Newbie

Joined: Wed Aug 27, 2003 5:31 am
Posts: 10
Hi,
After 2 days' scrutiny and hack on Hibernate source code. Finnally, I find the bug has nothing to do with Hibernate or underlying JDBC driver, it was caused by multiple invocations on Session.delete() with the same persistent object. Becuase the object was deleted by first call, the second pass would make batch update count 0, which Hibernate assume it would be 1. And thus the excpetion.

So remember this caveat: Never delete() a persistence object more than once! This may sound stupid, but actually in complicate nested loops it very likely you fail to pay attention to.

Enjoy Hibernate ! ;-)

Regards,
Justin


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 3:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hmmmmm this raises an interesting point that I had not been aware of before.

This code:

Code:
foo = (Foo) session.load(Foo.class, fooId);
session.delete(foo);
session.delete(foo);


works just fine. This code:

Code:
foo = (Foo) session.load(Foo.class, fooId);
session.delete(foo);
session.flush();
session.delete(foo);


is broken, since flush disassociates deleted instances.

This is Bad. Not sure if anything can be done about it though :(

Damn.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 05, 2004 4:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Probably it could be catched earlier and produce a nicer error message than "batch update rowcount wrong" ?


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.