3. Running JUnit Tests

It is recommended that the Hibernate unit tests be executed using the same dialect and version of JDBC that will be used in production, to ensure that the configuration setting, hibernate.jdbc.batch_versioned_data, is set properly. The value for hibernate.jdbc.batch_versioned_data determines if Hibernate will use batches for updating versioned data (an optimization).

Optimistic locking relies on the ability to obtain the number of rows updated. If the JDBC driver does not return update counts for each command in a batch, then hibernate.jdbc.batch_versioned_data should be set to "false".

The unit tests use the settings in etc/hibernate.properties. The value for hibernate.jdbc.batch_versioned_data is set to true in that file. If the unit tests involving optimistic locking fail, then the appropriate value for this flag is false. Some versions of Oracle JDBC do not support returning update counts for each command in a batch, so it is particularly important to test using the same version of JDBC as will be used in production.