I run a test in a subclass AbstractTransactionalTestNGSpringContextTestswhere I run tests in a partial Spring context. Each test runs inside a transaction that rolls back at the end to leave the database intact.
One test is written to the database via Hibernate, while the other is read from the same database using JdbcTemplate, both use the same data source.
I find that I cannot see hibernation updates when requested through JdbcTemplate. This makes sense, as each one apparently gets its own connection from the connection pool and therefore works as part of its own transaction.
I saw signs that they have the ability to separate the connection from the transaction, but I don’t understand how best to set this up, especially with the factory connection. All of these components are declared as Spring beans. Can anyone give me any directions?
Edit:
Well, I ran into the problem of reading any documentation and the HibernateTransactionManager class state that it is definitely possible: "This transaction manager is suitable for applications that use a single Hibernate SessionFactory session to access transactional data, but also supports direct access to data in a transaction ( i.e. simple JDBC code working with the same DataSource) ... ",
, , , . , , , . , .