Oracle and Batch update returned unexpected row count from update exception

Issue:

If you are using Oracle as the repository database and you are experiencing the following exception after scheduling many reports perhaps hundreds, try the suggestions below.

####<Nov 21, 2011 11:46:56 AM EST> <Notice> <Stdout> <qdcls0759> <WBIDEVServer01> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1321894016835> <000000> <11:46:56,833 ERROR HibernateDaoImpl,[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)':82 - Hibernate DataAccessException
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [3]; actual row count: -1; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [3]; actual row count: -1; expected: 1
Caused by:
org.hibernate.StaleStateException: Batch update returned unexpected row count from update [3]; actual row count: -1; expected: 1


Resolution:

See the following link to see if it is similar to what you are experiencing.

https://forums.oracle.com/forums/thread.jspa?threadID=532945

In this link, there is no explanation on why the Oracle driver behaves in a non-compliant way and there is no definitive solution. However, it indicates that you can avoid it by setting hibernate.jdbc.batch_size to 3 (also known as a magic number). To do this in JasperReports Server, edit WEB-INF/applicationContext.xml. Find the bean named sessionFactory and add the property hibernate.jdbc.batch_size to hibernateProperties with value of 3.

<prop key="hibernate.jdbc.batch_size">3</prop>

You can also try to update the Oracle JDBC driver to a newer version and see if the problem had been fixed. You can try contacting Oracle Support if you need further assistance with this issue..


Ref. Case #00022797 -- 06:55, 25 November 2011 (UTC)  

Feedback