Closed
Description
Describe the bug
I have a test of a query that updates a column in multiple rows using a where clause and spring.jpa.properties.hibernate.jdbc.batch_size=25
and I get a "JDBC batching is disabled." error.
Expected behavior
No error because it's a single query highly optimized.
Actual behavior
"JDBC batching is disabled." error.
To Reproduce
I added a test in ExpectJdbcBatchingWithoutBatchSizeTest
@RunWith(QuickPerfJUnitRunner.class)
public static class AClassHavingAMethodAnnotatedWithExpectJdbcBatchingAndExecutingOneUpdateBatched extends SqlTestBase {
@Override
protected Properties getHibernateProperties() {
String hibernateDialect = MemoryDatabaseHibernateDialect.INSTANCE.getHibernateDialect();
return anHibernateConfig()
.withBatchSize(30)
.build(hibernateDialect);
}
@Test
@ExpectJdbcBatching()
@DisplaySqlOfTestMethodBody
public void execute_one_update_in_batch_mode() {
executeInATransaction(entityManager -> {
String updateQueryAsString = "UPDATE Book SET title='Newer book'";
Query query = entityManager.createNativeQuery(updateQueryAsString);
query.executeUpdate();
});
}
}
@Test public void
should_pass_with_one_update_and_batch_mode() {
Class<?> testClass = AClassHavingAMethodAnnotatedWithExpectJdbcBatchingAndExecutingOneUpdateBatched.class;
PrintableResult testResult = testResult(testClass);
assertThat(testResult.failureCount()).isZero();
}
The output shows that BatchSize is 0 for the update but for me it should not trigger an error, maybe there should be a filter on Batch:False
?
Time:1, Success:True, Type:Prepared, Batch:False, QuerySize:1, BatchSize:0, Query:["
UPDATE
Book
SET
title='Newer book'"], Params:[()]
Use @DisplaySql to also see queries before and after test execution.
java.lang.AssertionError: a performance property is not respected
[PERF] JDBC batching is disabled.
You should check that hibernate.jdbc.batch_size Hibernate property has a positive value.
A batch size value between 5 and 30 is generally recommended.
Versions
- QuickPerf: 1.0.1-SNAPSHOT
- JDK: 11
- OS: Windows 10
- Database (if SQL annotation bug): Postgresql 12.4
Additional context (Add any other context about the problem here.)
Metadata
Metadata
Assignees
Labels
No labels