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 theDBRef
if the property is a reference.Returns theDocumentReference
if the property is a reference.getEvaluationContext
(Object rootObject) Obtain theEvaluationContext
for a specific root object.Returns the key to be used to store the value of the property inside a MongoDocument
.int
Returns the order of the field if defined.Class<?>
Returns theJava FieldType
of the field a property is persisted to.boolean
Returns whether the property uses an annotated field name throughField
.boolean
Returns whether the property is aDBRef
.boolean
Returns whether the property is aDocumentReference
.boolean
Returns whether the property is explicitly marked as an identifier property of the owningPersistentEntity
.boolean
Returns true when property being annotated withLanguage
.boolean
Also considers fields as id that are of supported id type and name.boolean
Returns true whether the property indicates the documents language either by having aMongoPersistentProperty.getFieldName()
equal to language or being annotated withLanguage
.boolean
Returns whether the property holds the documents score calculated by text search.boolean
Returns 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, usePropertyAccess
Methods 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, isMap
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.springframework.data.mongodb.core.mapping.MongoPersistentProperty
hasExplicitWriteTarget, isUnwrapped, usePropertyAccess
Methods 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:
isIdProperty
in interfacePersistentProperty<MongoPersistentProperty>
- Overrides:
isIdProperty
in classAnnotationBasedPersistentProperty<MongoPersistentProperty>
- See Also:
-
SUPPORTED_ID_PROPERTY_NAMES
SUPPORTED_ID_TYPES
-
isExplicitIdProperty
public boolean isExplicitIdProperty()Description copied from interface:MongoPersistentProperty
Returns 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:
isExplicitIdProperty
in interfaceMongoPersistentProperty
- Returns:
-
getFieldName
Returns the key to be used to store the value of the property inside a MongoDocument
.- Specified by:
getFieldName
in interfaceMongoPersistentProperty
- Returns:
-
getFieldType
Description copied from interface:MongoPersistentProperty
Returns theJava FieldType
of the field a property is persisted to.- Specified by:
getFieldType
in interfaceMongoPersistentProperty
- Returns:
- See Also:
-
hasExplicitFieldName
public boolean hasExplicitFieldName()Description copied from interface:MongoPersistentProperty
Returns whether the property uses an annotated field name throughField
.- Specified by:
hasExplicitFieldName
in interfaceMongoPersistentProperty
- Returns:
- true if
Field
having non blankField.value()
present. - Since:
- 1.7
-
getFieldOrder
public int getFieldOrder()Description copied from interface:MongoPersistentProperty
Returns the order of the field if defined. Will return -1 if undefined.- Specified by:
getFieldOrder
in interfaceMongoPersistentProperty
- Returns:
-
writeNullValues
public boolean writeNullValues()Description copied from interface:MongoPersistentProperty
Returns whether the property should be written to the database if its value is null.- Specified by:
writeNullValues
in interfaceMongoPersistentProperty
- Returns:
- See Also:
-
createAssociation
- Specified by:
createAssociation
in classAbstractPersistentProperty<MongoPersistentProperty>
-
isDbReference
public boolean isDbReference()Description copied from interface:MongoPersistentProperty
Returns whether the property is aDBRef
. If this returns true you can expectMongoPersistentProperty.getDBRef()
to return an non-null value.- Specified by:
isDbReference
in interfaceMongoPersistentProperty
- Returns:
-
isDocumentReference
public boolean isDocumentReference()Description copied from interface:MongoPersistentProperty
Returns whether the property is aDocumentReference
. If this returns true you can expectMongoPersistentProperty.getDocumentReference()
to return an non-null value.- Specified by:
isDocumentReference
in interfaceMongoPersistentProperty
- Returns:
-
getDBRef
Description copied from interface:MongoPersistentProperty
Returns theDBRef
if the property is a reference.- Specified by:
getDBRef
in interfaceMongoPersistentProperty
- Returns:
- See Also:
-
getDocumentReference
Description copied from interface:MongoPersistentProperty
Returns theDocumentReference
if the property is a reference.- Specified by:
getDocumentReference
in interfaceMongoPersistentProperty
- Returns:
- null if not present.
- See Also:
-
isLanguageProperty
public boolean isLanguageProperty()Description copied from interface:MongoPersistentProperty
Returns true whether the property indicates the documents language either by having aMongoPersistentProperty.getFieldName()
equal to language or being annotated withLanguage
.- Specified by:
isLanguageProperty
in interfaceMongoPersistentProperty
- Returns:
-
isExplicitLanguageProperty
public boolean isExplicitLanguageProperty()Description copied from interface:MongoPersistentProperty
Returns true when property being annotated withLanguage
.- Specified by:
isExplicitLanguageProperty
in interfaceMongoPersistentProperty
- Returns:
-
isTextScoreProperty
public boolean isTextScoreProperty()Description copied from interface:MongoPersistentProperty
Returns whether the property holds the documents score calculated by text search.
It's marked withTextScore
.- Specified by:
isTextScoreProperty
in interfaceMongoPersistentProperty
- Returns:
-
getEvaluationContext
Obtain theEvaluationContext
for a specific root object.- Parameters:
rootObject
- can be null.- Returns:
- never null.
- Since:
- 3.3
-
getEncryptionKeyIds
- Specified by:
getEncryptionKeyIds
in interfaceMongoPersistentProperty
- Returns:
- the resolved encryption keyIds if applicable. An empty
Collection
if no keyIds specified. null noEncrypted
annotation found.
-