Repository navigation
Closes a transaction gap in the streaming paths added in 4.2.0: a JpaCrudProvider operation
invoked from a deferred callback running on a different thread than the one that produced it (a
streamed export's writer, most notably) could hit Spring's shared EntityManager refusing
getTransaction() outright, since Spring reserves that call to @Transactional. Also adds row
deduplication to ListQuery/EntityListQuery, for a filter that joins a to-many relation.
Added
freddy-cruder-jpa
JpaTransactionRunner— how aJpaCrudProviderruns an operation that needs a transaction
around anEntityManager.JpaTransactionRunnersholds the single instance every provider in
the JVM uses — install a different one withJpaTransactionRunners.install(...)instead of
threading it through every provider's constructor. Defaults to
JpaTransactionRunner.resourceLocal(), the same behavior as before (delegates to
JpaUtils.requireTransaction/requireTransactionStream).ListQuery/EntityListQuerygained adistinctflag: aboolean distinctconstructor
parameter, and adistinct()/distinct(boolean)method returning a copy of the query with it
set — composable with any existing constructor. Needed when a filter or source joins a to-many
relation, which otherwise repeats a row once per match on the joined side; Hibernate 6 no longer
deduplicates that implicitly.JpaCrudProvider,FilterableJpaCrudProvider,FilterableOwnedJpaCrudProvider,
JpaProjectedCrudProviderandJpaOwnedProjectedCrudProvidernow go through
JpaTransactionRunners.current()instead of callingJpaUtils.requireTransaction/
requireTransactionStreamdirectly.
freddy-cruder-spring-data-jpa
SpringJpaTransactionRunner— aJpaTransactionRunnerbacked by a Spring
PlatformTransactionManager: honors anEntityManageralready joined to a transaction, or opens
a new Spring-managed one on the calling thread otherwise.- Auto-configuration installs it once the application context is ready — nothing to configure.
Fixed
- A
JpaCrudProvider'sstream()— and, through it, a streaming export — invoked from a callback
running on a thread with no active Spring transaction (the case forStreamingResponseBody's
deferred write) used to throwIllegalStateException: Not allowed to create transaction on shared EntityManager. Resolved automatically oncefreddy-cruder-spring-data-jpais on the classpath.
Migration
Nothing to migrate — both changes are additive and backward compatible. distinct defaults to
false everywhere it wasn't explicitly requested before.