spring-framework
spring-framework copied to clipboard
Test for unclosed EM after implicit query transaction under NEVER propagation.
I've failed to mock this completely, but IRL a subsequent call to, say, persist
uses an already opened EM instead of throwing.
EM is closed on exit from executeWithoutResult
.
Initially caught this in a system with schema-based multi-tenancy, where I've tried to force no transaction (and no current connection) on call of tenant iterating method with @Transactional(NEVER)
and got the iterations accessing the same tenant's schema.
IMO, there should be no synchronization unless transaction is open, but a code comment in AbstractPlatformTransactionManager#getTransaction(TransactionDefinition definition) says otherwise.