Package io.micronaut.data.model.runtime
Class RuntimePersistentEntity<T>
java.lang.Object
io.micronaut.data.model.AbstractPersistentEntity
io.micronaut.data.model.runtime.RuntimePersistentEntity<T>
- Type Parameters:
T
- The type
- All Implemented Interfaces:
io.micronaut.core.annotation.AnnotationMetadataProvider
,io.micronaut.core.annotation.AnnotationSource
,io.micronaut.core.naming.Named
,PersistentElement
,PersistentEntity
public class RuntimePersistentEntity<T>
extends AbstractPersistentEntity
implements PersistentEntity
Runtime implementation of
PersistentEntity
that uses pre-computed Introspected
bean data and is completely stateless.- Since:
- 1.0
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Constructor Summary
ConstructorsConstructorDescriptionRuntimePersistentEntity
(@NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection) Default constructor.RuntimePersistentEntity
(@NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, Collection<io.micronaut.core.beans.BeanProperty<T, Object>> beanProperties) Default constructor.RuntimePersistentEntity
(@NonNull Class<T> type) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Does cascade the persist to any of the associations.boolean
Does cascade the update to any of the associations.@NonNull String
@NonNull Collection<RuntimeAssociation<T>>
A list of the associations for this entity.@Nullable RuntimePersistentProperty<T>[]
The composite id.protected RuntimePersistentEntity<T>
Obtain an entity for the given type.@Nullable RuntimePersistentProperty<T>
Returns the identity of the instance.@Nullable RuntimePersistentProperty<T>
getIdentityByName
(String name) Obtains an identity PersistentProperty instance by name.io.micronaut.core.beans.BeanIntrospection<T>
@NonNull String
getName()
The entity name including any package prefix.@Nullable PersistentEntity
Returns the parent entity of this entity.@NonNull Collection<RuntimePersistentProperty<T>>
A list of properties to be persisted.A list of property names that a persistent.@Nullable RuntimePersistentProperty<T>
getPropertyByName
(String name) Obtains a PersistentProperty instance by name.@Nullable RuntimePersistentProperty<T>
Returns the version property.boolean
boolean
Has composite identity.boolean
Has identity.boolean
Does the entity have post-load event listeners.boolean
Does the entity have post-persist event listeners.boolean
Does the entity have post-remove event listeners.boolean
Does the entity have post-update event listeners.boolean
Does the entity have pre-persist event listeners.boolean
Does the entity have pre-remove event listeners.boolean
Does the entity have pre-update event listeners.boolean
isOwningEntity
(PersistentEntity owner) Returns whether the specified entity asserts ownership over this entity.protected void
Log error message.protected @NonNull AttributeConverter<Object,
Object> resolveConverter
(@NonNull Class<?> converterClass) Resolves a converter instance.toString()
Methods inherited from class io.micronaut.data.model.AbstractPersistentEntity
equals, findNamingStrategy, getAnnotationMetadata, getNamingStrategy, getPersistedName, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataProvider
findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, getAnnotationMetadata, getTargetAnnotationMetadata, 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
Methods inherited from interface io.micronaut.data.model.PersistentEntity
findNamingStrategy, getDecapitalizedName, getEmbedded, getNamingStrategy, getPath, getPropertyByPath, getPropertyPath, getPropertyPath, getRootEntity, getSimpleName, isEmbeddable, isRoot, isVersioned
-
Constructor Details
-
RuntimePersistentEntity
Default constructor.- Parameters:
type
- The type
-
RuntimePersistentEntity
public RuntimePersistentEntity(@NonNull @NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection) Default constructor.- Parameters:
introspection
- The introspection
-
RuntimePersistentEntity
public RuntimePersistentEntity(@NonNull @NonNull io.micronaut.core.beans.BeanIntrospection<T> introspection, Collection<io.micronaut.core.beans.BeanProperty<T, Object>> beanProperties) Default constructor.- Parameters:
introspection
- The introspectionbeanProperties
- The bean properties
-
-
Method Details
-
logDebug
Description copied from class:AbstractPersistentEntity
Log error message.- Overrides:
logDebug
in classAbstractPersistentEntity
- Parameters:
message
- The messagee
- The exception
-
resolveConverter
@NonNull protected @NonNull AttributeConverter<Object,Object> resolveConverter(@NonNull @NonNull Class<?> converterClass) Resolves a converter instance.- Parameters:
converterClass
- The converter class- Returns:
- converter instance
-
cascadesPersist
public boolean cascadesPersist()Does cascade the persist to any of the associations.- Returns:
- True if it does
-
cascadesUpdate
public boolean cascadesUpdate()Does cascade the update to any of the associations.- Returns:
- True if it does
-
hasPrePersistEventListeners
public boolean hasPrePersistEventListeners()Does the entity have pre-persist event listeners.- Returns:
- True if it does
-
hasPreRemoveEventListeners
public boolean hasPreRemoveEventListeners()Does the entity have pre-remove event listeners.- Returns:
- True if it does
-
hasPreUpdateEventListeners
public boolean hasPreUpdateEventListeners()Does the entity have pre-update event listeners.- Returns:
- True if it does
-
hasPostPersistEventListeners
public boolean hasPostPersistEventListeners()Does the entity have post-persist event listeners.- Returns:
- True if it does
-
hasPostUpdateEventListeners
public boolean hasPostUpdateEventListeners()Does the entity have post-update event listeners.- Returns:
- True if it does
-
hasPostRemoveEventListeners
public boolean hasPostRemoveEventListeners()Does the entity have post-remove event listeners.- Returns:
- True if it does
-
hasPostLoadEventListeners
public boolean hasPostLoadEventListeners()Does the entity have post-load event listeners.- Returns:
- True if it does
-
toString
-
getAliasName
- Specified by:
getAliasName
in interfacePersistentEntity
- Overrides:
getAliasName
in classAbstractPersistentEntity
- Returns:
- A name to use when referring to this element via an alias.
-
getIntrospection
- Returns:
- The underlying introspection.
-
getName
Description copied from interface:PersistentEntity
The entity name including any package prefix.- Specified by:
getName
in interfaceio.micronaut.core.naming.Named
- Specified by:
getName
in interfacePersistentEntity
- Returns:
- The entity name
-
hasCompositeIdentity
public boolean hasCompositeIdentity()Description copied from interface:PersistentEntity
Has composite identity.- Specified by:
hasCompositeIdentity
in interfacePersistentEntity
- Returns:
- The true if composite identity present
-
hasIdentity
public boolean hasIdentity()Description copied from interface:PersistentEntity
Has identity.- Specified by:
hasIdentity
in interfacePersistentEntity
- Returns:
- The true if identity present
-
getCompositeIdentity
Description copied from interface:PersistentEntity
The composite id.- Specified by:
getCompositeIdentity
in interfacePersistentEntity
- Returns:
- The composite id or null if there isn't one
-
getIdentity
Description copied from interface:PersistentEntity
Returns the identity of the instance.- Specified by:
getIdentity
in interfacePersistentEntity
- Returns:
- The identity or null if there isn't one
-
getVersion
Description copied from interface:PersistentEntity
Returns the version property.- Specified by:
getVersion
in interfacePersistentEntity
- Returns:
- the property
-
getPersistentProperties
Description copied from interface:PersistentEntity
A list of properties to be persisted.- Specified by:
getPersistentProperties
in interfacePersistentEntity
- Returns:
- A list of PersistentProperty instances
-
getAssociations
Description copied from interface:PersistentEntity
A list of the associations for this entity. This is typically a subset of the list returned byPersistentEntity.getPersistentProperties()
- Specified by:
getAssociations
in interfacePersistentEntity
- Returns:
- A list of associations
-
getPropertyByName
Description copied from interface:PersistentEntity
Obtains a PersistentProperty instance by name.- Specified by:
getPropertyByName
in interfacePersistentEntity
- Parameters:
name
- The name of the property- Returns:
- The PersistentProperty or null if it doesn't exist
-
getIdentityByName
Description copied from interface:PersistentEntity
Obtains an identity PersistentProperty instance by name.- Specified by:
getIdentityByName
in interfacePersistentEntity
- Parameters:
name
- The name of the identity property- Returns:
- The PersistentProperty or null if it doesn't exist
-
getPersistentPropertyNames
Description copied from interface:PersistentEntity
A list of property names that a persistent.- Specified by:
getPersistentPropertyNames
in interfacePersistentEntity
- Returns:
- A List of strings
-
isOwningEntity
Description copied from interface:PersistentEntity
Returns whether the specified entity asserts ownership over this entity.- Specified by:
isOwningEntity
in interfacePersistentEntity
- Parameters:
owner
- The owning entity- Returns:
- True if it does own this entity
-
getParentEntity
Description copied from interface:PersistentEntity
Returns the parent entity of this entity.- Specified by:
getParentEntity
in interfacePersistentEntity
- Returns:
- The ParentEntity instance
-
getEntity
Obtain an entity for the given type.- Parameters:
type
- The type- Returns:
- The entity
- Throws:
io.micronaut.core.beans.exceptions.IntrospectionException
- if the entity doesn't exist
-
getConstructorArguments
- Returns:
- The constructor arguments.
-
hasAutoPopulatedProperties
public boolean hasAutoPopulatedProperties()- Returns:
- Returns true if the entity has auto-populated properties.
-