Class MappingMongoEntityInformation<T,ID>
java.lang.Object
org.springframework.data.repository.core.support.PersistentEntityInformation<T,ID>
org.springframework.data.mongodb.repository.support.MappingMongoEntityInformation<T,ID>
- All Implemented Interfaces:
MongoEntityInformation<T,,ID> EntityInformation<T,,ID> EntityMetadata<T>
public class MappingMongoEntityInformation<T,ID>
extends PersistentEntityInformation<T,ID>
implements MongoEntityInformation<T,ID>
MongoEntityInformation implementation using a MongoPersistentEntity instance to lookup the necessary
information. Can be configured with a custom collection to be returned which will trump the one returned by the
MongoPersistentEntity if given.- Author:
- Oliver Gierke, Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a newMappingMongoEntityInformationfor the givenMongoPersistentEntity.MappingMongoEntityInformation(MongoPersistentEntity<T> entity, Class<ID> fallbackIdType) Creates a newMappingMongoEntityInformationfor the givenMongoPersistentEntityand fallback identifier type.MappingMongoEntityInformation(MongoPersistentEntity<T> entity, String customCollectionName) Creates a newMappingMongoEntityInformationfor the givenMongoPersistentEntityand custom collection name. -
Method Summary
Modifier and TypeMethodDescriptionReturn the collation for the entity or null ifnot defined.Returns the name of the collection the entity shall be persisted to.Returns the attribute that the id will be persisted to.getVersion(T entity) Returns the version value for the entity or null if the entity is notversioned.booleanReturns whether the entity uses optimistic locking.Methods inherited from class org.springframework.data.repository.core.support.PersistentEntityInformation
getId, getJavaType, isNewMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.data.repository.core.EntityInformation
getId, getRequiredId, isNewMethods inherited from interface org.springframework.data.repository.core.EntityMetadata
getJavaTypeMethods inherited from interface org.springframework.data.mongodb.repository.query.MongoEntityInformation
hasCollation
-
Constructor Details
-
MappingMongoEntityInformation
Creates a newMappingMongoEntityInformationfor the givenMongoPersistentEntity.- Parameters:
entity- must not be null.
-
MappingMongoEntityInformation
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, @Nullable Class<ID> fallbackIdType) Creates a newMappingMongoEntityInformationfor the givenMongoPersistentEntityand fallback identifier type.- Parameters:
entity- must not be null.fallbackIdType- can be null.
-
MappingMongoEntityInformation
Creates a newMappingMongoEntityInformationfor the givenMongoPersistentEntityand custom collection name.- Parameters:
entity- must not be null.customCollectionName- can be null.
-
-
Method Details
-
getCollectionName
Description copied from interface:MongoEntityInformationReturns the name of the collection the entity shall be persisted to.- Specified by:
getCollectionNamein interfaceMongoEntityInformation<T,ID> - Returns:
-
getIdAttribute
Description copied from interface:MongoEntityInformationReturns the attribute that the id will be persisted to.- Specified by:
getIdAttributein interfaceMongoEntityInformation<T,ID> - Returns:
-
getIdType
- Specified by:
getIdTypein interfaceEntityInformation<T,ID> - Overrides:
getIdTypein classPersistentEntityInformation<T,ID>
-
isVersioned
public boolean isVersioned()Description copied from interface:MongoEntityInformationReturns whether the entity uses optimistic locking.- Specified by:
isVersionedin interfaceMongoEntityInformation<T,ID> - Returns:
- true if the entity defines a
Versionproperty.
-
getVersion
Description copied from interface:MongoEntityInformationReturns the version value for the entity or null if the entity is notversioned.- Specified by:
getVersionin interfaceMongoEntityInformation<T,ID> - Parameters:
entity- must not be null- Returns:
- can be null.
-
getCollation
Description copied from interface:MongoEntityInformationReturn the collation for the entity or null ifnot defined.- Specified by:
getCollationin interfaceMongoEntityInformation<T,ID> - Returns:
- can be null.
-