Class BasicMongoPersistentProperty
java.lang.Object
org.springframework.data.mapping.model.AbstractPersistentProperty<P>
org.springframework.data.mapping.model.AnnotationBasedPersistentProperty<MongoPersistentProperty>
org.springframework.data.mongodb.core.mapping.BasicMongoPersistentProperty
- All Implemented Interfaces:
PersistentProperty<MongoPersistentProperty>,MongoPersistentProperty
- Direct Known Subclasses:
CachingMongoPersistentProperty
public class BasicMongoPersistentProperty
extends AnnotationBasedPersistentProperty<MongoPersistentProperty>
implements MongoPersistentProperty
MongoDB specific
PersistentProperty implementation.- Author:
- Oliver Gierke, Patryk Wasik, Thomas Darimont, Christoph Strobl, Mark Paluch, Divya Srivastava
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.data.mongodb.core.mapping.MongoPersistentProperty
MongoPersistentProperty.PropertyToFieldNameConverter -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBasicMongoPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder, FieldNamingStrategy fieldNamingStrategy) Creates a newBasicMongoPersistentProperty. -
Method Summary
Modifier and TypeMethodDescriptionprotected Association<MongoPersistentProperty>getDBRef()Returns theDBRefif the property is a reference.Returns theDocumentReferenceif the property is a reference.getEvaluationContext(Object rootObject) Obtain theEvaluationContextfor a specific root object.Returns the key to be used to store the value of the property inside a MongoDocument.intReturns the order of the field if defined.Class<?>Returns theJava FieldTypeof the field a property is persisted to.booleanReturns whether the property uses an annotated field name throughField.booleanReturns whether the property is aDBRef.booleanReturns whether the property is aDocumentReference.booleanReturns whether the property is explicitly marked as an identifier property of the owningPersistentEntity.booleanReturns true when property being annotated withLanguage.booleanAlso considers fields as id that are of supported id type and name.booleanReturns true whether the property indicates the documents language either by having aMongoPersistentProperty.getFieldName()equal to language or being annotated withLanguage.booleanReturns whether the property holds the documents score calculated by text search.booleanReturns whether the property should be written to the database if its value is null.Methods inherited from class org.springframework.data.mapping.model.AnnotationBasedPersistentProperty
findAnnotation, findPropertyOrOwnerAnnotation, getAssociationTargetTypeInformation, getSpelExpression, isAnnotationPresent, isAssociation, isTransient, isVersionProperty, isWritable, toString, usePropertyAccessMethods inherited from class org.springframework.data.mapping.model.AbstractPersistentProperty
equals, getActualType, getActualTypeInformation, getAssociation, getAssociationTargetType, getComponentType, getField, getGetter, getMapValueType, getName, getOwner, getPersistentEntityTypeInformation, getProperty, getRawType, getSetter, getType, getTypeInformation, getWither, hashCode, isArray, isCollectionLike, isEntity, isImmutable, isMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.springframework.data.mongodb.core.mapping.MongoPersistentProperty
hasExplicitWriteTarget, isUnwrapped, usePropertyAccessMethods inherited from interface org.springframework.data.mapping.PersistentProperty
findAnnotation, findPropertyOrOwnerAnnotation, getAccessorForOwner, getActualType, getAssociation, getAssociationTargetType, getAssociationTargetTypeInformation, getComponentType, getField, getGetter, getMapValueType, getName, getOwner, getPersistentEntityTypeInformation, getRawType, getRequiredAnnotation, getRequiredAssociation, getRequiredField, getRequiredGetter, getRequiredSetter, getRequiredWither, getSetter, getSpelExpression, getType, getTypeInformation, getWither, hasActualTypeAnnotation, isAnnotationPresent, isArray, isAssociation, isCollectionLike, isEntity, isImmutable, isMap, isTransient, isVersionProperty, isWritable
-
Field Details
-
ID_FIELD_NAME
- See Also:
-
-
Constructor Details
-
BasicMongoPersistentProperty
public BasicMongoPersistentProperty(Property property, MongoPersistentEntity<?> owner, SimpleTypeHolder simpleTypeHolder, @Nullable FieldNamingStrategy fieldNamingStrategy) Creates a newBasicMongoPersistentProperty.- Parameters:
property- the source property.owner- the owing entity.simpleTypeHolder- must not be null.fieldNamingStrategy- can be null.
-
-
Method Details
-
isIdProperty
public boolean isIdProperty()Also considers fields as id that are of supported id type and name.- Specified by:
isIdPropertyin interfacePersistentProperty<MongoPersistentProperty>- Overrides:
isIdPropertyin classAnnotationBasedPersistentProperty<MongoPersistentProperty>- See Also:
-
SUPPORTED_ID_PROPERTY_NAMESSUPPORTED_ID_TYPES
-
isExplicitIdProperty
public boolean isExplicitIdProperty()Description copied from interface:MongoPersistentPropertyReturns whether the property is explicitly marked as an identifier property of the owningPersistentEntity. A property is an explicit id property if it is annotated with @seeId.- Specified by:
isExplicitIdPropertyin interfaceMongoPersistentProperty- Returns:
-
getFieldName
Returns the key to be used to store the value of the property inside a MongoDocument.- Specified by:
getFieldNamein interfaceMongoPersistentProperty- Returns:
-
getFieldType
Description copied from interface:MongoPersistentPropertyReturns theJava FieldTypeof the field a property is persisted to.- Specified by:
getFieldTypein interfaceMongoPersistentProperty- Returns:
- See Also:
-
hasExplicitFieldName
public boolean hasExplicitFieldName()Description copied from interface:MongoPersistentPropertyReturns whether the property uses an annotated field name throughField.- Specified by:
hasExplicitFieldNamein interfaceMongoPersistentProperty- Returns:
- true if
Fieldhaving non blankField.value()present. - Since:
- 1.7
-
getFieldOrder
public int getFieldOrder()Description copied from interface:MongoPersistentPropertyReturns the order of the field if defined. Will return -1 if undefined.- Specified by:
getFieldOrderin interfaceMongoPersistentProperty- Returns:
-
writeNullValues
public boolean writeNullValues()Description copied from interface:MongoPersistentPropertyReturns whether the property should be written to the database if its value is null.- Specified by:
writeNullValuesin interfaceMongoPersistentProperty- Returns:
- See Also:
-
createAssociation
- Specified by:
createAssociationin classAbstractPersistentProperty<MongoPersistentProperty>
-
isDbReference
public boolean isDbReference()Description copied from interface:MongoPersistentPropertyReturns whether the property is aDBRef. If this returns true you can expectMongoPersistentProperty.getDBRef()to return an non-null value.- Specified by:
isDbReferencein interfaceMongoPersistentProperty- Returns:
-
isDocumentReference
public boolean isDocumentReference()Description copied from interface:MongoPersistentPropertyReturns whether the property is aDocumentReference. If this returns true you can expectMongoPersistentProperty.getDocumentReference()to return an non-null value.- Specified by:
isDocumentReferencein interfaceMongoPersistentProperty- Returns:
-
getDBRef
Description copied from interface:MongoPersistentPropertyReturns theDBRefif the property is a reference.- Specified by:
getDBRefin interfaceMongoPersistentProperty- Returns:
- See Also:
-
getDocumentReference
Description copied from interface:MongoPersistentPropertyReturns theDocumentReferenceif the property is a reference.- Specified by:
getDocumentReferencein interfaceMongoPersistentProperty- Returns:
- null if not present.
- See Also:
-
isLanguageProperty
public boolean isLanguageProperty()Description copied from interface:MongoPersistentPropertyReturns true whether the property indicates the documents language either by having aMongoPersistentProperty.getFieldName()equal to language or being annotated withLanguage.- Specified by:
isLanguagePropertyin interfaceMongoPersistentProperty- Returns:
-
isExplicitLanguageProperty
public boolean isExplicitLanguageProperty()Description copied from interface:MongoPersistentPropertyReturns true when property being annotated withLanguage.- Specified by:
isExplicitLanguagePropertyin interfaceMongoPersistentProperty- Returns:
-
isTextScoreProperty
public boolean isTextScoreProperty()Description copied from interface:MongoPersistentPropertyReturns whether the property holds the documents score calculated by text search.
It's marked withTextScore.- Specified by:
isTextScorePropertyin interfaceMongoPersistentProperty- Returns:
-
getEvaluationContext
Obtain theEvaluationContextfor a specific root object.- Parameters:
rootObject- can be null.- Returns:
- never null.
- Since:
- 3.3
-
getEncryptionKeyIds
- Specified by:
getEncryptionKeyIdsin interfaceMongoPersistentProperty- Returns:
- the resolved encryption keyIds if applicable. An empty
Collectionif no keyIds specified. null noEncryptedannotation found.
-