Skip to content

Commit 0e169aa

Browse files
mp911dechristophstrobl
authored andcommitted
Document createCollection(…) annotation usage.
Closes: #4978 Original Pull Request: #4979
1 parent 030035c commit 0e169aa

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/MongoOperations.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,21 @@ public <T> T execute(SessionCallback<T> action, Consumer<ClientSession> onComple
259259

260260
/**
261261
* Create an uncapped collection with a name based on the provided entity class.
262+
* <p>
263+
* This method derives {@link CollectionOptions} from the given {@code entityClass} using
264+
* {@link org.springframework.data.mongodb.core.mapping.Document} and
265+
* {@link org.springframework.data.mongodb.core.mapping.TimeSeries} annotations to determine:
266+
* <ul>
267+
* <li>Collation</li>
268+
* <li>TimeSeries time and meta fields, granularity and {@code expireAfter}</li>
269+
* </ul>
270+
* Any other options such as change stream options, schema-based details (validation, encryption) are not considered
271+
* and must be provided through {@link #createCollection(Class, CollectionOptions)} or
272+
* {@link #createCollection(String, CollectionOptions)}.
262273
*
263274
* @param entityClass class that determines the collection to create.
264275
* @return the created collection.
276+
* @see #createCollection(Class, CollectionOptions)
265277
*/
266278
<T> MongoCollection<Document> createCollection(Class<T> entityClass);
267279

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/ReactiveMongoOperations.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,21 @@ default ReactiveSessionScoped withSession(Supplier<ClientSession> sessionProvide
214214

215215
/**
216216
* Create an uncapped collection with a name based on the provided entity class.
217+
* <p>
218+
* This method derives {@link CollectionOptions} from the given {@code entityClass} using
219+
* {@link org.springframework.data.mongodb.core.mapping.Document} and
220+
* {@link org.springframework.data.mongodb.core.mapping.TimeSeries} annotations to determine:
221+
* <ul>
222+
* <li>Collation</li>
223+
* <li>TimeSeries time and meta fields, granularity and {@code expireAfter}</li>
224+
* </ul>
225+
* Any other options such as change stream options, schema-based details (validation, encryption) are not considered
226+
* and must be provided through {@link #createCollection(Class, CollectionOptions)} or
227+
* {@link #createCollection(String, CollectionOptions)}.
217228
*
218229
* @param entityClass class that determines the collection to create.
219230
* @return the created collection.
231+
* @see #createCollection(Class, CollectionOptions)
220232
*/
221233
<T> Mono<MongoCollection<Document>> createCollection(Class<T> entityClass);
222234

0 commit comments

Comments
 (0)