My Library Docs

Multi-root Sidebar

flex-layout

  • Getting Started

  • Guides

  • Reference

typed-rx-http

  • Getting Started

  • Guides

  • Reference

global-rx-state

  • Getting Started

  • Guides

  • Reference

webflux-fe-dev-assistant

reactive-mongo-dsl

Spring Integration

Connects the mapping, collection naming, and reactive lifecycle of ReactiveMongoTemplate to the MongoExecutionContext adapter without pulling in Spring Data MongoDB as a core dependency.


Spring Data MongoDB is maintained by the application.
build.gradle
text

The core library does not directly depend on Spring Data MongoDB. To use the ReactiveMongoTemplate configuration from an existing Spring application, the MongoExecutionContext adapter is provided at the application layer.

SpringReactiveMongoExecutionContext adapter
SpringReactiveMongoExecutionContext.java
java

In the actual implementation, add the necessary Spring/MongoDB imports to the above class. The key is to connect entity read/write to MongoConverter, collection names to ReactiveMongoTemplate, and session initiation to the corresponding MongoClient.

Resolver and DSL Bean registration
MongoTemplateNameResolver.java
java
ReactiveMongoDslConfiguration.java
java
Scope connected in the adapter

@Document / collection name

Use ReactiveMongoTemplate#getCollectionName(...).

@Id / @Field / custom conversions

Use MongoConverter for entity ↔ Document conversion.

Reactive auditing

Connecting beforePersist(...) to ReactiveBeforeConvertCallback applies reactive auditing callbacks in the save() chain.

ReactiveAfterSaveCallback

Can be called in afterPersist(...) after a successful write.

Spring QueryMapper

Not applicable. DSL String field paths are based on actual MongoDB document field names.

Spring DataAccessException

Does not perform automatic conversion. The actual operation is performed by the Reactive Streams Driver.

When using @Field
java

Spring mapping is applied for entity save/retrieve conversion, but the String path of DSL conditions does not go through Spring QueryMapper. However, the exact id path segment is normalized to _id according to DSL rules.

Spring transactions and DSL transactions are separate.
© 2026 Byeolnaerim. All rights reserved.IntroductionPrivacy Policy