You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
DATAMONGO-1798 - Introduce @mongoid annotation for fine grained id conversion control.
@mongoid allows more fine grained control over id conversion by specifying the intended id target type. This allows to skip the automatic to ObjectId conversion of values that happen to be valid ObjectId hex strings.
public class PlainStringId {
@mongoid String id; // treated as String no matter what
}
public class PlainObjectId {
@mongoid ObjectId id; // treated as ObjectId
}
public class StringToObjectId {
@mongoid(FieldType.OBJECT_ID) String id; // treated as ObjectId if the value is a valid ObjectId hex string
}
Original pull request: spring-projects#617.
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/convert/MappingMongoConverter.java
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentEntity.java
+16
Original file line number
Diff line number
Diff line change
@@ -59,4 +59,20 @@ public interface MongoPersistentEntity<T> extends PersistentEntity<T, MongoPersi
59
59
*/
60
60
booleanhasTextScoreProperty();
61
61
62
+
/**
63
+
* Returns the entities {@literal id} type of {@literal null} if the entity has no {@literal id} property.
64
+
*
65
+
* @return {@literal null} if the entity does not have an {@link #hasIdProperty() id property}.
Copy file name to clipboardExpand all lines: spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/mapping/MongoPersistentProperty.java
0 commit comments