Package org.springframework.data.mapping
Interface PersistentEntity<T,P extends PersistentProperty<P>>
- All Superinterfaces:
Iterable<P>
- All Known Subinterfaces:
MutablePersistentEntity<T,P>
- All Known Implementing Classes:
BasicPersistentEntity
Represents a persistent entity. The order of the properties returned via the
Iterator is not guaranteed.- Author:
- Oliver Gierke, Graeme Rocher, Jon Brisbin, Patryk Wasik, Mark Paluch, Christoph Strobl, Johannes Englmeier
-
Method Summary
Modifier and TypeMethodDescriptiondefault voiddoWithAll(PropertyHandler<P> handler) Applies the givenPropertyHandlerto both allPersistentPropertys as well as all inverse properties of allAssociations.voiddoWithAssociations(AssociationHandler<P> handler) voidvoiddoWithProperties(PropertyHandler<P> handler) voiddoWithProperties(SimplePropertyHandler handler) Applies the givenSimplePropertyHandlerto allPersistentPropertys contained in thisPersistentEntity.<A extends Annotation>
AfindAnnotation(Class<A> annotationType) Looks up the annotation of the given type on thePersistentEntity.getIdentifierAccessor(Object bean) Returns theIdentifierAccessorfor the given bean.Returns the id property of thePersistentEntity.Returns theInstanceCreatorMetadatato be used to instantiate objects of thisPersistentEntity.getName()The entity name including any package prefix.Deprecated.getPersistentProperties(Class<? extends Annotation> annotationType) Returns all properties equipped with anAnnotationof the given type.default PgetPersistentProperty(Class<? extends Annotation> annotationType) Returns the first property equipped with anAnnotationof the given type.getPersistentProperty(String name) Obtains aPersistentPropertyinstance by name.<B> PersistentPropertyAccessor<B>getPropertyAccessor(B bean) Returns aPersistentPropertyAccessorto access property values of the given bean.getPropertyPathAccessor(B bean) Returns aPersistentPropertyPathAccessorto access property values of the given bean.default <A extends Annotation>
AgetRequiredAnnotation(Class<A> annotationType) Returns the required annotation of the given type on thePersistentEntity.default PReturns the id property of thePersistentEntity.default PReturns thePersistentPropertywith the given name.default PReturns the version property of thePersistentEntity.getType()Returns the resolved Java type of this entity.Returns the alias to be used when storing type information.Returns theTypeInformationbacking thisPersistentEntity.Returns the version property of thePersistentEntity.booleanReturns whether thePersistentEntityhas an id property.booleanReturns whether thePersistentEntityhas a version property.<A extends Annotation>
booleanisAnnotationPresent(Class<A> annotationType) Checks whether the annotation of the given type is present on thePersistentEntity.default booleanisConstructorArgument(PersistentProperty<?> property) Deprecated.since 3.0, useisCreatorArgument(PersistentProperty)instead.booleanisCreatorArgument(PersistentProperty<?> property) Returns whether the givenPersistentPropertyis referred to by a creator argument of thePersistentEntity.booleanisIdProperty(PersistentProperty<?> property) Returns whether the givenPersistentPropertyis the id property of the entity.booleanReturns whether the entity is considered immutable, i.e. clients shouldn't attempt to change instances via thePersistentPropertyAccessorobtained viagetPropertyAccessor(Object).booleanReturns whether the given bean is considered new according to the static metadata.booleanisVersionProperty(PersistentProperty<?> property) Returns whether the givenPersistentPropertyis the version property of the entity.booleanReturns whether the entity needs properties to be populated, i.e. if any property exists that's not initialized by the constructor.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getName
String getName()The entity name including any package prefix.- Returns:
- must never return null.
-
getPersistenceConstructor
Deprecated.since 3.0, usegetInstanceCreatorMetadata().Returns thePreferredConstructorto be used to instantiate objects of thisPersistentEntity.- Returns:
- null in case no suitable constructor for automatic construction can be found. This usually
indicates that the instantiation of the object of that persistent entity is done through either a
customer
EntityInstantiatoror handled by custom conversion mechanisms entirely.
-
getInstanceCreatorMetadata
Returns theInstanceCreatorMetadatato be used to instantiate objects of thisPersistentEntity.- Returns:
- null in case no suitable creation mechanism for automatic construction can be found. This
usually indicates that the instantiation of the object of that persistent entity is done through either a
customer
EntityInstantiatoror handled by custom conversion mechanisms entirely. - Since:
- 3.0
-
isConstructorArgument
Deprecated.since 3.0, useisCreatorArgument(PersistentProperty)instead.Returns whether the givenPersistentPropertyis referred to by a constructor argument of thePersistentEntity.- Parameters:
property- can be null.- Returns:
- true if the given
PersistentPropertyis referred to by a constructor argument or false if not or null.
-
isCreatorArgument
Returns whether the givenPersistentPropertyis referred to by a creator argument of thePersistentEntity.- Parameters:
property- can be null.- Returns:
- true if the given
PersistentPropertyis referred to by a creator argument or false if not or null.
-
isIdProperty
Returns whether the givenPersistentPropertyis the id property of the entity.- Parameters:
property- can be null.- Returns:
- true given property is the entities id.
-
isVersionProperty
Returns whether the givenPersistentPropertyis the version property of the entity.- Parameters:
property- can be null.- Returns:
- true given property is used as version.
-
getIdProperty
Returns the id property of thePersistentEntity. Can be null in case this is an entity completely handled by a custom conversion.- Returns:
- the id property of the
PersistentEntity.
-
getRequiredIdProperty
Returns the id property of thePersistentEntity.- Returns:
- the id property of the
PersistentEntity. - Throws:
IllegalStateException- ifPersistentEntitydoes not define an id property.- Since:
- 2.0
-
getVersionProperty
Returns the version property of thePersistentEntity. Can be null in case no version property is available on the entity.- Returns:
- the version property of the
PersistentEntity.
-
getRequiredVersionProperty
Returns the version property of thePersistentEntity. Can be null in case no version property is available on the entity.- Returns:
- the version property of the
PersistentEntity. - Throws:
IllegalStateException- ifPersistentEntitydoes not define a version property.- Since:
- 2.0
-
getPersistentProperty
Obtains aPersistentPropertyinstance by name.- Parameters:
name- The name of the property. Can be null.- Returns:
- the
PersistentPropertyor null if it doesn't exist.
-
getRequiredPersistentProperty
Returns thePersistentPropertywith the given name.- Parameters:
name- the name of the property. Can be null or empty.- Returns:
- the
PersistentPropertywith the given name. - Throws:
IllegalStateException- in case no property with the given name exists.
-
getPersistentProperty
Returns the first property equipped with anAnnotationof the given type.- Parameters:
annotationType- must not be null.- Returns:
- null if no property found with given annotation type.
- Since:
- 1.8
-
getPersistentProperties
Returns all properties equipped with anAnnotationof the given type.- Parameters:
annotationType- must not be null.- Returns:
- empty
Iteratorif no match found. Never null. - Since:
- 2.0
-
hasIdProperty
boolean hasIdProperty()Returns whether thePersistentEntityhas an id property. If this call returns true,getIdProperty()will return a non-null value.- Returns:
- true if entity has an id property.
-
hasVersionProperty
boolean hasVersionProperty()Returns whether thePersistentEntityhas a version property. If this call returns true,getVersionProperty()will return a non-null value.- Returns:
- true if entity has a version property.
-
getType
Returns the resolved Java type of this entity.- Returns:
- The underlying Java class for this entity. Never null.
-
getTypeAlias
Alias getTypeAlias()Returns the alias to be used when storing type information. Might be null to indicate that there was no alias defined through the mapping metadata.- Returns:
-
getTypeInformation
TypeInformation<T> getTypeInformation()Returns theTypeInformationbacking thisPersistentEntity.- Returns:
-
doWithProperties
Applies the givenPropertyHandlerto allPersistentPropertys contained in thisPersistentEntity. The iteration order is undefined.- Parameters:
handler- must not be null.
-
doWithProperties
Applies the givenSimplePropertyHandlerto allPersistentPropertys contained in thisPersistentEntity. The iteration order is undefined.- Parameters:
handler- must not be null.
-
doWithAssociations
Applies the givenAssociationHandlerto allAssociationcontained in thisPersistentEntity. The iteration order is undefined.- Parameters:
handler- must not be null.
-
doWithAssociations
Applies the givenSimpleAssociationHandlerto allAssociationcontained in thisPersistentEntity. The iteration order is undefined.- Parameters:
handler- must not be null.
-
doWithAll
Applies the givenPropertyHandlerto both allPersistentPropertys as well as all inverse properties of allAssociations. The iteration order is undefined.- Parameters:
handler- must not be null.- Since:
- 2.5
-
findAnnotation
Looks up the annotation of the given type on thePersistentEntity.- Parameters:
annotationType- must not be null.- Returns:
- null if not found.
- Since:
- 1.8
-
getRequiredAnnotation
default <A extends Annotation> A getRequiredAnnotation(Class<A> annotationType) throws IllegalStateException Returns the required annotation of the given type on thePersistentEntity.- Parameters:
annotationType- must not be null.- Returns:
- the annotation.
- Throws:
IllegalStateException- if the requiredannotationTypeis not found.- Since:
- 2.0
-
isAnnotationPresent
Checks whether the annotation of the given type is present on thePersistentEntity.- Parameters:
annotationType- must not be null.- Returns:
- true if
Annotationof given type is present. - Since:
- 2.0
-
getPropertyAccessor
Returns aPersistentPropertyAccessorto access property values of the given bean.- Parameters:
bean- must not be null.- Returns:
- new
PersistentPropertyAccessor. - Since:
- 1.10
-
getPropertyPathAccessor
Returns aPersistentPropertyPathAccessorto access property values of the given bean.- Parameters:
bean- must not be null.- Returns:
- a new
PersistentPropertyPathAccessor - Since:
- 2.3
-
getIdentifierAccessor
Returns theIdentifierAccessorfor the given bean.- Parameters:
bean- must not be null.- Returns:
- new
IdentifierAccessor. - Since:
- 1.10
-
isNew
Returns whether the given bean is considered new according to the static metadata.- Parameters:
bean- must not be null.- Returns:
- whether the given bean is considered a new instance.
- Throws:
IllegalArgumentException- in case the given bean is not an instance of the typ represented by thePersistentEntity.
-
isImmutable
boolean isImmutable()Returns whether the entity is considered immutable, i.e. clients shouldn't attempt to change instances via thePersistentPropertyAccessorobtained viagetPropertyAccessor(Object).- Returns:
- Since:
- 2.1
- See Also:
-
requiresPropertyPopulation
boolean requiresPropertyPopulation()Returns whether the entity needs properties to be populated, i.e. if any property exists that's not initialized by the constructor.- Returns:
- Since:
- 2.1
-
getInstanceCreatorMetadata().