Package io.micronaut.data.model
Interface PersistentEntity
-
- All Superinterfaces:
io.micronaut.core.annotation.AnnotationMetadataProvider
,io.micronaut.core.annotation.AnnotationSource
,io.micronaut.core.naming.Named
,PersistentElement
- All Known Implementing Classes:
AbstractPersistentEntity
,RuntimePersistentEntity
,SourcePersistentEntity
public interface PersistentEntity extends PersistentElement
Models a persistent entity and provides an API that can be used both within the compiler and at runtime. TheAnnotationMetadata
provided is consistent both at runtime and compilation time.- Since:
- 1.0
- Author:
- Graeme Rocher
- See Also:
PersistentProperty
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description java.util.Optional<NamingStrategy>
findNamingStrategy()
Find the naming strategy that is defined for the entity.java.lang.String
getAliasName()
default java.util.Collection<? extends Association>
getAssociations()
A list of the associations for this entity.PersistentProperty[]
getCompositeIdentity()
The composite id.default java.lang.String
getDecapitalizedName()
default java.util.Collection<Embedded>
getEmbedded()
A list of embedded associations for this entity.PersistentProperty
getIdentity()
Returns the identity of the instance.default PersistentProperty
getIdentityByName(java.lang.String name)
Obtains an identity PersistentProperty instance by name.java.lang.String
getName()
The entity name including any package prefix.NamingStrategy
getNamingStrategy()
Obtain the naming strategy for the entity.PersistentEntity
getParentEntity()
Returns the parent entity of this entity.default java.util.Optional<java.lang.String>
getPath(java.lang.String camelCasePath)
Computes a dot separated property path for the given camel case path.java.util.Collection<? extends PersistentProperty>
getPersistentProperties()
A list of properties to be persisted.java.util.Collection<java.lang.String>
getPersistentPropertyNames()
A list of property names that a persistent.PersistentProperty
getPropertyByName(java.lang.String name)
Obtains a PersistentProperty instance by name.default java.util.Optional<PersistentProperty>
getPropertyByPath(java.lang.String path)
Return a property for a dot separated property path such asfoo.bar.prop
.default PersistentPropertyPath
getPropertyPath(java.lang.String path)
Return aPersistentPropertyPath
by path such asfoo.bar.prop
.default PersistentPropertyPath
getPropertyPath(java.lang.String[] propertyPath)
Return aPersistentPropertyPath
by path such asfoo.bar.prop
.default PersistentEntity
getRootEntity()
Obtains the root entity of an inheritance hierarchy.default java.lang.String
getSimpleName()
PersistentProperty
getVersion()
Returns the version property.default boolean
hasCompositeIdentity()
Has composite identity.default boolean
hasIdentity()
Has identity.default boolean
isEmbeddable()
boolean
isOwningEntity(PersistentEntity owner)
Returns whether the specified entity asserts ownership over this entity.default boolean
isRoot()
Whether this entity is a root entity.default boolean
isVersioned()
Is the entity versioned for optimistic locking.static <T> RuntimePersistentEntity<T>
of(io.micronaut.core.beans.BeanIntrospection<T> introspection)
Creates a new persistent entity representation of the given type.static <T> RuntimePersistentEntity<T>
of(java.lang.Class<T> type)
Creates a new persistent entity representation of the given type.-
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
-
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, isAnnotationPresent, isDeclaredAnnotationPresent, synthesize, synthesizeDeclared
-
Methods inherited from interface io.micronaut.data.model.PersistentElement
getPersistedName
-
-
-
-
Method Detail
-
getName
@NonNull java.lang.String getName()
The entity name including any package prefix.- Specified by:
getName
in interfaceio.micronaut.core.naming.Named
- Returns:
- The entity name
-
getAliasName
@NonNull java.lang.String getAliasName()
- Returns:
- A name to use when referring to this element via an alias.
-
hasCompositeIdentity
default boolean hasCompositeIdentity()
Has composite identity.- Returns:
- The true if composite identity present
-
hasIdentity
default boolean hasIdentity()
Has identity.- Returns:
- The true if identity present
-
getCompositeIdentity
@Nullable PersistentProperty[] getCompositeIdentity()
The composite id.- Returns:
- The composite id or null if there isn't one
-
getIdentity
@Nullable PersistentProperty getIdentity()
Returns the identity of the instance.- Returns:
- The identity or null if there isn't one
-
getVersion
@Nullable PersistentProperty getVersion()
Returns the version property.- Returns:
- the property
-
isVersioned
default boolean isVersioned()
Is the entity versioned for optimistic locking.- Returns:
- true if versioned
-
getPersistentProperties
@NonNull java.util.Collection<? extends PersistentProperty> getPersistentProperties()
A list of properties to be persisted.- Returns:
- A list of PersistentProperty instances
-
getAssociations
@NonNull default java.util.Collection<? extends Association> getAssociations()
A list of the associations for this entity. This is typically a subset of the list returned bygetPersistentProperties()
- Returns:
- A list of associations
-
getEmbedded
@NonNull default java.util.Collection<Embedded> getEmbedded()
A list of embedded associations for this entity. This is typically a subset of the list returned bygetPersistentProperties()
- Returns:
- A list of associations
-
getPropertyByName
@Nullable PersistentProperty getPropertyByName(java.lang.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
-
getIdentityByName
@Nullable default PersistentProperty getIdentityByName(java.lang.String name)
Obtains an identity PersistentProperty instance by name.- Parameters:
name
- The name of the identity property- Returns:
- The PersistentProperty or null if it doesn't exist
-
getPersistentPropertyNames
@NonNull java.util.Collection<java.lang.String> getPersistentPropertyNames()
A list of property names that a persistent.- Returns:
- A List of strings
-
isEmbeddable
default boolean isEmbeddable()
- Returns:
- Is the entity embeddable.
-
getSimpleName
@NonNull default java.lang.String getSimpleName()
- Returns:
- The simple name without the package of entity
-
getDecapitalizedName
@NonNull default java.lang.String getDecapitalizedName()
- Returns:
- Returns the name of the class decapitalized form
-
isOwningEntity
boolean isOwningEntity(PersistentEntity owner)
Returns whether the specified entity asserts ownership over this entity.- Parameters:
owner
- The owning entity- Returns:
- True if it does own this entity
-
getParentEntity
@Nullable PersistentEntity getParentEntity()
Returns the parent entity of this entity.- Returns:
- The ParentEntity instance
-
getPath
default java.util.Optional<java.lang.String> getPath(java.lang.String camelCasePath)
Computes a dot separated property path for the given camel case path.- Parameters:
camelCasePath
- The camel case path- Returns:
- The dot separated version or null if it cannot be computed
-
getRootEntity
@NonNull default PersistentEntity getRootEntity()
Obtains the root entity of an inheritance hierarchy.- Returns:
- The root entity
-
isRoot
default boolean isRoot()
Whether this entity is a root entity.- Returns:
- True if it is a root entity
-
getPropertyByPath
default java.util.Optional<PersistentProperty> getPropertyByPath(java.lang.String path)
Return a property for a dot separated property path such asfoo.bar.prop
.- Parameters:
path
- The path- Returns:
- The property
-
getPropertyPath
@Nullable default PersistentPropertyPath getPropertyPath(@NonNull java.lang.String path)
Return aPersistentPropertyPath
by path such asfoo.bar.prop
. .- Parameters:
path
- The path- Returns:
- The properties
-
getPropertyPath
@Nullable default PersistentPropertyPath getPropertyPath(@NonNull java.lang.String[] propertyPath)
Return aPersistentPropertyPath
by path such asfoo.bar.prop
. .- Parameters:
propertyPath
- The path- Returns:
- The properties
-
getNamingStrategy
@NonNull NamingStrategy getNamingStrategy()
Obtain the naming strategy for the entity.- Returns:
- The naming strategy
-
findNamingStrategy
@NonNull java.util.Optional<NamingStrategy> findNamingStrategy()
Find the naming strategy that is defined for the entity.- Returns:
- The optional naming strategy
-
of
@NonNull static <T> RuntimePersistentEntity<T> of(@NonNull java.lang.Class<T> type)
Creates a new persistent entity representation of the given type. The type must be annotated withIntrospected
. This method will create a new instance on demand and does not cache.- Type Parameters:
T
- The generic type- Parameters:
type
- The type- Returns:
- The entity
-
of
@NonNull static <T> RuntimePersistentEntity<T> of(@NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection)
Creates a new persistent entity representation of the given type. The type must be annotated withIntrospected
. This method will create a new instance on demand and does not cache.- Type Parameters:
T
- The generic type- Parameters:
introspection
- The introspection- Returns:
- The entity
-
-