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 SummaryModifier 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.IterableforEach, iterator, spliterator
- 
Method Details- 
getNameString getName()The entity name including any package prefix.- Returns:
- must never return null.
 
- 
getPersistenceConstructorDeprecated.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.
 
- 
getInstanceCreatorMetadataReturns 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
 
- 
isConstructorArgumentDeprecated.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.
 
- 
isCreatorArgumentReturns 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.
 
- 
isIdPropertyReturns whether the givenPersistentPropertyis the id property of the entity.- Parameters:
- property- can be null.
- Returns:
- true given property is the entities id.
 
- 
isVersionPropertyReturns whether the givenPersistentPropertyis the version property of the entity.- Parameters:
- property- can be null.
- Returns:
- true given property is used as version.
 
- 
getIdPropertyReturns 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.
 
- 
getRequiredIdPropertyReturns the id property of thePersistentEntity.- Returns:
- the id property of the PersistentEntity.
- Throws:
- IllegalStateException- if- PersistentEntitydoes not define an id property.
- Since:
- 2.0
 
- 
getVersionPropertyReturns 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.
 
- 
getRequiredVersionPropertyReturns 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- if- PersistentEntitydoes not define a version property.
- Since:
- 2.0
 
- 
getPersistentPropertyObtains aPersistentPropertyinstance by name.- Parameters:
- name- The name of the property. Can be null.
- Returns:
- the PersistentPropertyor null if it doesn't exist.
 
- 
getRequiredPersistentPropertyReturns 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.
 
- 
getPersistentPropertyReturns 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
 
- 
getPersistentPropertiesReturns 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
 
- 
hasIdPropertyboolean 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.
 
- 
hasVersionPropertyboolean 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.
 
- 
getTypeReturns the resolved Java type of this entity.- Returns:
- The underlying Java class for this entity. Never null.
 
- 
getTypeAliasAlias 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:
 
- 
getTypeInformationTypeInformation<T> getTypeInformation()Returns theTypeInformationbacking thisPersistentEntity.- Returns:
 
- 
doWithPropertiesApplies the givenPropertyHandlerto allPersistentPropertys contained in thisPersistentEntity. The iteration order is undefined.- Parameters:
- handler- must not be null.
 
- 
doWithPropertiesApplies the givenSimplePropertyHandlerto allPersistentPropertys contained in thisPersistentEntity. The iteration order is undefined.- Parameters:
- handler- must not be null.
 
- 
doWithAssociationsApplies the givenAssociationHandlerto allAssociationcontained in thisPersistentEntity. The iteration order is undefined.- Parameters:
- handler- must not be null.
 
- 
doWithAssociationsApplies the givenSimpleAssociationHandlerto allAssociationcontained in thisPersistentEntity. The iteration order is undefined.- Parameters:
- handler- must not be null.
 
- 
doWithAllApplies 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
 
- 
findAnnotationLooks up the annotation of the given type on thePersistentEntity.- Parameters:
- annotationType- must not be null.
- Returns:
- null if not found.
- Since:
- 1.8
 
- 
getRequiredAnnotationdefault <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 required- annotationTypeis not found.
- Since:
- 2.0
 
- 
isAnnotationPresentChecks 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
 
- 
getPropertyAccessorReturns aPersistentPropertyAccessorto access property values of the given bean.- Parameters:
- bean- must not be null.
- Returns:
- new PersistentPropertyAccessor.
- Since:
- 1.10
 
- 
getPropertyPathAccessorReturns aPersistentPropertyPathAccessorto access property values of the given bean.- Parameters:
- bean- must not be null.
- Returns:
- a new PersistentPropertyPathAccessor
- Since:
- 2.3
 
- 
getIdentifierAccessorReturns theIdentifierAccessorfor the given bean.- Parameters:
- bean- must not be null.
- Returns:
- new IdentifierAccessor.
- Since:
- 1.10
 
- 
isNewReturns 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 the- PersistentEntity.
 
- 
isImmutableboolean 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:
 
- 
requiresPropertyPopulationboolean 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().