public final class GormSpringDataSessionSupport extends java.lang.Object
Binds a GORM-owned ClientSession into Spring Data MongoDB's thread-bound resources so that
a MongoTemplate executes within the same MongoDB transaction GORM started.
This lives in org.springframework.data.mongodb because Spring Data's
MongoResourceHolder (the resource a MongoTemplate looks up to discover an active
session) is package-private. Only the holder construction needs that access; binding, unbinding
and rebinding go through the public TransactionSynchronizationManager keyed by the
MongoDatabaseFactory, so callers can treat the holder as an opaque object.
Invariant: GORM owns the ClientSession lifecycle (it commits/aborts and
closes it). The holder bound here is effectively read-only for Spring Data — MongoTemplate
only reads the session from it; nothing in this module asks Spring Data to commit or close the
session, so there is no double-close.
Compatibility: this depends on the package-private
MongoResourceHolder(ClientSession, MongoDatabaseFactory) constructor of Spring Data MongoDB
(verified against the 5.x line shipped with Spring Boot 4). A change to that internal type would
break compilation, which the dedicated coupling smoke test surfaces explicitly. Because this is a
deliberate split package with Spring Data, this module is supported on the class path only and is
not compatible with the Java Platform Module System (JPMS) module path.
| Type Params | Return Type | Name and description |
|---|---|---|
|
public static void |
bindClientSession(MongoDatabaseFactory databaseFactory, ClientSession clientSession)Binds the given session to the current thread for the given factory, if nothing is bound yet. |
| Methods inherited from class | Name |
|---|---|
class java.lang.Object |
java.lang.Object#equals(java.lang.Object), java.lang.Object#getClass(), java.lang.Object#hashCode(), java.lang.Object#notify(), java.lang.Object#notifyAll(), java.lang.Object#toString(), java.lang.Object#wait(), java.lang.Object#wait(long), java.lang.Object#wait(long, int) |
Binds the given session to the current thread for the given factory, if nothing is bound yet.