Code Monkey home page Code Monkey logo

Comments (3)

wilkinsona avatar wilkinsona commented on September 17, 2024 1

Thanks for the sample. The change in behaviour is due to Hibernate which Spring Boot 3.3.x upgrades to 6.5.x. If I run the tests with Spring Boot 3.3.1 and Hibernate downgraded to 6.4.9.Final they all pass.

I'm not sure that a fully understand the purpose of the tests, but they appear to be relying on some side-effects of Hibernate's behavior despite not actually using JPA. Specifically, they seem to be relying up Hibernate calling getConnection() on the DataSource. I would guess that some optimisations in Hibernate 6.5.x mean that it no longer gets a connection so eagerly which results in connectionReadOnlyCaptor not capturing anything.

You can see similar failures with Spring Boot 3.2.7 if you change the tests from @DataJpaTest to @JdbcTest. Doing so takes Hibernate out of the picture and means that getConnection() is never called on the DataSource. As far as I can tell, you need to rework your tests to avoid relying upon a side-effect of how Hibernate behaves.

from spring-boot.

philwebb avatar philwebb commented on September 17, 2024 1

Just coming here to say the same thing. Adding the following to the build scripts makes the tests pass:

buildscript {
    extra.apply {
        set("hibernate.version", "6.4.9.Final")
    }
}

To cause seems to be a change in org.hibernate.resource.jdbc.internal.AbstractLogicalConnectionImplementor where the commit() method now checks isPhysicallyConnected() which returns false.

from spring-boot.

icepuma avatar icepuma commented on September 17, 2024 1

Thanks for the explanation!

I think I got the issue and related commit.

Adding a simple entityManager.createQuery("select 1").getResultList(); to all inner transactions fixes nearly all tests, because it forces a connection acquisition (took it from the test from the linked commit) and hence a call for dataSource.getConnection().

from spring-boot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.