Browse Source

Mention java.util.Date _id to ObjectId conversion.

See #5092
See #5078
Original pull request #5080
pull/5109/head
Christoph Strobl 1 month ago committed by Jens Schauder
parent
commit
fec7754531
No known key found for this signature in database
GPG Key ID: 2BE5D185CD2A1CE6
  1. 1
      src/main/antora/modules/ROOT/pages/mongodb/template-crud-operations.adoc

1
src/main/antora/modules/ROOT/pages/mongodb/template-crud-operations.adoc

@ -191,6 +191,7 @@ When you use the `MappingMongoConverter`, certain rules govern how properties fr @@ -191,6 +191,7 @@ When you use the `MappingMongoConverter`, certain rules govern how properties fr
The following outlines what type conversion, if any, is done on the property mapped to the `_id` document field when using the `MappingMongoConverter` (the default for `MongoTemplate`).
. If possible, an `id` property or field declared as a `String` in the Java class is converted to and stored as an `ObjectId` by using a Spring `Converter<String, ObjectId>`. Valid conversion rules are delegated to the MongoDB Java driver. If it cannot be converted to an `ObjectId`, then the value is stored as a string in the database.
. An `id` property or field declared as `Date` is converted to and stored as `ObjectId`.
. An `id` property or field declared as `BigInteger` in the Java class is converted to and stored as an `ObjectId` by using a Spring `Converter<BigInteger, ObjectId>`.
If no field or property specified in the previous sets of rules is present in the Java class, an implicit `_id` file is generated by the driver but not mapped to a property or field of the Java class.

Loading…
Cancel
Save