INSERTs/UPDATEs no longer executed as JDBC Batch statements

Hello,

we are using Hibernate via SpringDataJPA and have a non-functional requirement that our application must not connect to database during startup time.

Because Hibernate by default always seems to use a database connection during application startup to retrieve some database meta data we configured parameter spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults=false
like discussed in https://MultiTenant Hibernate + Spring boot - How to prevent it from looking up ….

This worked fine until upgrading from Spring Boot 2.5 (hibernate-core version 5.4.33) to Spring Boot 2.6 (hibernate-core version 5.6.7):
Since then INSERT and UPDATE statements are executed as single statements instead of JDBC batch statements which has a major performance impact.

We debugged this effect and it seems to be caused by commit 6c53a9d1abf1bb2e38cfbb986a8bb33188aacfb9 - after this commit the configured spring.jpa.properties.hibernate.jdbc.batch_size seems to be “overruled” by ExtractedDatabaseMetaDataImpl#supportsBatchUpdates() which returns false if DatabaseMetaData was not read from a database connection.

Is there a way in current hibernate-core version 5.6.7 to fulfill the two requirements “no database connection at application startup” AND “INSERT / UPDATE with JDBC Batch statements”?
If not: where could a requirement to Hibernate be placed?

Thanks a lot for any suggestions

Could you please create a JIRA issue and provide a reproducer for this?

Hello @beikov ,

thanks for your answer - I will gladly create a JIRA issue, but I have one question left about the reproducer:

I cannot directly sent our current code, because it contains many maven dependencies and parts for our functional domain, so the real problem will not be that obvious.

Would there be any possibility for the Hibernate team to use one of your own test applications, configure hibernate.temp.use_jdbc_metadata_defaults=false and see whether INSERTs are not executed as JDBC Batches?

Otherwise I would try to create a simple Spring Boot application that runs into this problem - would it be ok if I would sent it as a zipfile containing the maven project?

I thought it was obvious, but the following link will lead to a repository, that contains a sample project, which can be used for reproducing issues, so that we can easily see what is going on: hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub

Hello @beikov ,

thanks a lot for your support, it was easy to reconstruct the effect using the sample project.

I opened HHH-15281

1 Like