Hibernate – troubleshooting SQL

Home » SQL » Hibernate – troubleshooting SQL
SQL, Uncategorized No Comments

When SQL has issue we get this from Hibernate:

org.hibernate.exception.GenericJDBCException: Could not execute JDBC batch update

The problem is that this error is not very helpful. It doesn’t tell us what SQL statement is causing the problem. The solution is to add the following system properties:

-Dhibernate.statement_cache.size=0 
-Dhibernate.jdbc.batch_size=0 
-Dhibernate.jdbc.use_scrollable_resultset=false
-Dhibernate.bytecode.use_reflection_optimizer=false
-Dhibernate.show_sql=true

This would prevent Hibernate from BATCHING and therefore tell us exactly which SQL statement is causing the error.

See: https://stackoverflow.com/questions/25718015/hibernate-could-not-execute-jdbc-batch-update