Execution Context & Resolver
MongoTemplateResolverがkeyごとのMongoExecutionContextを選択し、DriverMongoExecutionContextがdatabase、session、mappingの境界を提供する方法を説明します。
MongoTemplateResolver契約
MongoTemplateResolver.java
javaReactiveMongoDsl<K>는 key마다 MongoExecutionContext를 가져옵니다. MongoExecutionContext가 MongoDatabase, ClientSession, collection naming, entity ↔ Document mapping과 save lifecycle hook의 경계를 담당합니다.
DriverMongoExecutionContext
기본 collection 이름은 entity simple class name을 decapitalize해서 결정합니다. 프로젝트의 실제 naming 규칙이 다르면 생성자에 collection-name resolver를 전달합니다.
コレクション名付け
collection名がアプリケーションのライフサイクル中に完全に固定されている場合、DriverMongoExecutionContext.cachedCollectionNameResolver(...)を使用できます。tenant/request/timeに応じて名前が変わるresolverにはキャッシュヘルパーを使用しません。
セッションスコープとトランザクション
getTxJob(...)で作成されたClientSessionはMongoExecutionContext#getSessionScope()が同じDSL実行にのみ伝播します。DriverMongoExecutionContextは基本的に自分のMongoClientをセッションスコープとして使用します。