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
ConstructorDescriptionCreates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
.MappingMongoEntityInformation
(MongoPersistentEntity<T> entity, Class<ID> fallbackIdType) Creates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
and fallback identifier type.MappingMongoEntityInformation
(MongoPersistentEntity<T> entity, String customCollectionName) Creates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
and 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
.boolean
Returns whether the entity uses optimistic locking.Methods inherited from class org.springframework.data.repository.core.support.PersistentEntityInformation
getId, getJavaType, isNew
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.data.repository.core.EntityInformation
getId, getRequiredId, isNew
Methods inherited from interface org.springframework.data.repository.core.EntityMetadata
getJavaType
Methods inherited from interface org.springframework.data.mongodb.repository.query.MongoEntityInformation
hasCollation
-
Constructor Details
-
MappingMongoEntityInformation
Creates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
.- Parameters:
entity
- must not be null.
-
MappingMongoEntityInformation
public MappingMongoEntityInformation(MongoPersistentEntity<T> entity, @Nullable Class<ID> fallbackIdType) Creates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
and fallback identifier type.- Parameters:
entity
- must not be null.fallbackIdType
- can be null.
-
MappingMongoEntityInformation
Creates a newMappingMongoEntityInformation
for the givenMongoPersistentEntity
and custom collection name.- Parameters:
entity
- must not be null.customCollectionName
- can be null.
-
-
Method Details
-
getCollectionName
Description copied from interface:MongoEntityInformation
Returns the name of the collection the entity shall be persisted to.- Specified by:
getCollectionName
in interfaceMongoEntityInformation<T,
ID> - Returns:
-
getIdAttribute
Description copied from interface:MongoEntityInformation
Returns the attribute that the id will be persisted to.- Specified by:
getIdAttribute
in interfaceMongoEntityInformation<T,
ID> - Returns:
-
getIdType
- Specified by:
getIdType
in interfaceEntityInformation<T,
ID> - Overrides:
getIdType
in classPersistentEntityInformation<T,
ID>
-
isVersioned
public boolean isVersioned()Description copied from interface:MongoEntityInformation
Returns whether the entity uses optimistic locking.- Specified by:
isVersioned
in interfaceMongoEntityInformation<T,
ID> - Returns:
- true if the entity defines a
Version
property.
-
getVersion
Description copied from interface:MongoEntityInformation
Returns the version value for the entity or null if the entity is notversioned
.- Specified by:
getVersion
in interfaceMongoEntityInformation<T,
ID> - Parameters:
entity
- must not be null- Returns:
- can be null.
-
getCollation
Description copied from interface:MongoEntityInformation
Return the collation for the entity or null ifnot defined
.- Specified by:
getCollation
in interfaceMongoEntityInformation<T,
ID> - Returns:
- can be null.
-