jdbcFetchSize seems to be ignored

Hi there,

We have upgraded some of our apps to Spring Boot 3, which also brings Hibernate 6. Since the upgrade we have noticed that the hibernate.jdbc.fetch_size property is not being respected. After some debugging I can see that the jdbcFetchSize field in SessionFactoryOptionsBuilder is being set properly but it looks like it’s not being read. Compared it with Hibernate 5 and I can see it being read as expected. Before creating a ticket for this I thought I would check it here, maybe someone has a solution.

There is a Spring issue that was closed: spring.jpa.properties.hibernate.jdbc.fetch_size not working Spring 3.X and Oracle · Issue #2835 · spring-projects/spring-data-jpa · GitHub
and a Stack Overflow post as well: java - spring.jpa.properties.hibernate.jdbc.fetch_size not working for Spring Framework 6.x and Oracle? - Stack Overflow

Thanks,
Balazs

From looking at the code, I can see that the JDBC fetch size is applied in org.hibernate.engine.jdbc.internal.StatementPreparerImpl#setStatementFetchSize. You can debug that to understand what is happening in your case.

I tried that but it never gets called. What I can see is that when running the query with Hibernate 6 it uses a StatementPreparationTemplate whereas on H5 it uses a QueryStatementPreparationTemplate.

this is stack on H6

and this is on H5:

Looks like a bug. Please create an issue in the issue tracker(https://hibernate.atlassian.net) with a test case(hibernate-test-case-templates/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) that reproduces the issue.

@beikov @balazs
Wanted to check if there is a bug created for this.

https://hibernate.atlassian.net/browse/HHH-16872

Following Bug has been created to track this.