Spring Data Core

org.springframework.data.mapping
Interface PersistentEntity<T,P extends PersistentProperty<P>>

All Known Subinterfaces:
MutablePersistentEntity<T,P>
All Known Implementing Classes:
BasicPersistentEntity

public interface PersistentEntity<T,P extends PersistentProperty<P>>

Represents a persistent entity.

Author:
Oliver Gierke, Graeme Rocher, Jon Brisbin, Patryk Wasik

Method Summary
 void doWithAssociations(AssociationHandler<P> handler)
          Applies the given AssociationHandler to all Association contained in this PersistentEntity.
 void doWithProperties(PropertyHandler<P> handler)
          Applies the given PropertyHandler to all PersistentPropertys contained in this PersistentEntity.
 P getIdProperty()
          Returns the id property of the PersistentEntity.
 String getName()
          The entity name including any package prefix.
 PreferredConstructor<T,P> getPersistenceConstructor()
          Returns the PreferredConstructor to be used to instantiate objects of this PersistentEntity.
 P getPersistentProperty(String name)
          Obtains a PersistentProperty instance by name.
 Class<T> getType()
          Returns the resolved Java type of this entity.
 Object getTypeAlias()
          Returns the alias to be used when storing type information.
 TypeInformation<T> getTypeInformation()
          Returns the TypeInformation backing this PersistentEntity.
 P getVersionProperty()
          Returns the version property of the PersistentEntity.
 boolean hasIdProperty()
          Returns whether the PersistentEntity has an id property.
 boolean hasVersionProperty()
          Returns whether the PersistentEntity has a version property.
 boolean isConstructorArgument(PersistentProperty<?> property)
          Returns whether the given PersistentProperty is referred to by a constructor argument of the PersistentEntity.
 boolean isIdProperty(PersistentProperty<?> property)
          Returns whether the given PersistentProperty is the id property of the entity.
 boolean isVersionProperty(PersistentProperty<?> property)
          Returns whether the given PersistentProperty is the version property of the entity.
 

Method Detail

getName

String getName()
The entity name including any package prefix.

Returns:
must never return null

getPersistenceConstructor

PreferredConstructor<T,P> getPersistenceConstructor()
Returns the PreferredConstructor to be used to instantiate objects of this PersistentEntity.

Returns:
null in case no suitable constructor for automatic construction can be found. This usually indicates that the instantiation of the object of tthat persistent entity is done through either a customer EntityInstantiator or handled by custom conversion mechanisms entirely.

isConstructorArgument

boolean isConstructorArgument(PersistentProperty<?> property)
Returns whether the given PersistentProperty is referred to by a constructor argument of the PersistentEntity.

Parameters:
property -
Returns:
true if the given PersistentProperty is referred to by a constructor argument or false if not or null.

isIdProperty

boolean isIdProperty(PersistentProperty<?> property)
Returns whether the given PersistentProperty is the id property of the entity.

Parameters:
property -
Returns:

isVersionProperty

boolean isVersionProperty(PersistentProperty<?> property)
Returns whether the given PersistentProperty is the version property of the entity.

Parameters:
property -
Returns:

getIdProperty

P getIdProperty()
Returns the id property of the PersistentEntity. Can be null in case this is an entity completely handled by a custom conversion.

Returns:
the id property of the PersistentEntity.

getVersionProperty

P getVersionProperty()
Returns the version property of the PersistentEntity. Can be null in case no version property is available on the entity.

Returns:
the version property of the PersistentEntity.

getPersistentProperty

P getPersistentProperty(String name)
Obtains a PersistentProperty instance by name.

Parameters:
name - The name of the property
Returns:
the PersistentProperty or null if it doesn't exist.

hasIdProperty

boolean hasIdProperty()
Returns whether the PersistentEntity has an id property. If this call returns true, getIdProperty() will return a non-null value.

Returns:

hasVersionProperty

boolean hasVersionProperty()
Returns whether the PersistentEntity has a version property. If this call returns true, getVersionProperty() will return a non-null value.

Returns:

getType

Class<T> getType()
Returns the resolved Java type of this entity.

Returns:
The underlying Java class for this entity

getTypeAlias

Object 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 the TypeInformation backing this PersistentEntity.

Returns:

doWithProperties

void doWithProperties(PropertyHandler<P> handler)
Applies the given PropertyHandler to all PersistentPropertys contained in this PersistentEntity.

Parameters:
handler - must not be null.

doWithAssociations

void doWithAssociations(AssociationHandler<P> handler)
Applies the given AssociationHandler to all Association contained in this PersistentEntity.

Parameters:
handler - must not be null.

Spring Data Core

Copyright © 2011-2013-2013 Pivotal. All Rights Reserved.