In our javaEE application, running on Wildfly 27.0.1.Final with its provided Hibernate 6.1.5, we mainly use our own custom ORM, but we also mix in a bit of JPA / Hibernate.
The goal is that one request should use one connection for everything, no matter what the mixture of our ORM and Hibernate looks like, and commit should only happen once, at the end of the request.
Using connection = sessionImplementor.getJdbcConnectionAccess().obtainConnection()
it looks like I get a different connection than what Hibernate uses itself. At least, Hibernate doesn’t see the changes I do on that connection.
Using connection = sessionImplementor.doReturningWork(connection -> connection)
seems to work (added it 30 mins ago, so can’t be sure everything works just yet), but it seems really ugly, as if I’m breaking out of a controlled environment.
Is there a “right” way to do this?