-->
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.  [ 2 posts ] 
Author Message
 Post subject: Batching & Hibernate Stateless Session & JBoss...
PostPosted: Tue Mar 07, 2006 3:52 am 
Newbie

Joined: Tue Mar 07, 2006 3:37 am
Posts: 4
Hello,

We have a piece of code that works flawlessly under Weblogic 8.1, but doesn't work under JBoss 4.0. This code performs batch update using 'BatchingBatcher' class in Hibernate and uses 'Hibernate Stateless session'. Under JBoss we get the following exception:

Code:
Caused by: java.sql.SQLException: Closed Statement
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
   at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
   at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:3523)
   at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10538)
   at org.jboss.resource.adapter.jdbc.WrappedStatement.executeBatch(WrappedStatement.java:487)
   at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
   at org.hibernate.jdbc.BatchingBatcher.addToBatch(BatchingBatcher.java:34)
   at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2062)



While debugging I noticed that the 'batchUpdate' instance variable in AbstractBatcher *automagically* gets cleared during the update process. Under JBoss, this is of the type 'WrappedStatement'.

Is there some kinda timeout that's getting triggered under JBoss? Our transaction timeout is set to 3600.

Any help will be greatly appreciated.


Top
 Profile  
 
 Post subject: Bug in AbstractBatcher?
PostPosted: Wed Mar 08, 2006 8:48 pm 
Newbie

Joined: Tue Mar 07, 2006 3:37 am
Posts: 4
Turns out that this is not really a JBoss issue, but a Hibernate issue. It looks like the 'AbstractBatcher' class in Hibernate is not quite set up correctly to handle batch updates. We changed the following method in this class to fix this issue:


Code:
   public boolean hasOpenResources() {

            //return resultSetsToClose.size() > 0 || statementsToClose.size() > 0;
            return resultSetsToClose.size() > 0 || statementsToClose.size() > 0 || (batchUpdate != null);
   }




When a connection is closed, this method is used to check if there are any open resources. In batch update mode, Hibernate doesn't use the 'resultSetsToClose' & 'statementsToClose' variables; but uses the 'batchUpdate' variable. As such, this method needs to return 'true' if batch update is in process.

As for, why this worked in Weblogic and not in JBoss, my only explanation is that JBoss does a better job of cleaning resources after the connection is closed than Weblogic does.

It seems like, when a connection is closed, JBoss closes all the associated PreparedStatements; but Weblogic keeps them open. In this particular case, it seems like, Weblogic was re-attaching a connection to the old PreparedStatement.

Hope this all makes sense. Can someone from the Hibernate team tell me if this is indeed a bug? Is there a better way to fix it? Your help will be appreciated. Thanks.


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