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
Runtime implementation of PersistentEntity that uses pre-computed Introspected bean data and is completely stateless.
Since:
1.0
Author:
graemerocher
  • Constructor Details

    • RuntimePersistentEntity

      public RuntimePersistentEntity(Class<T> type)
      Default constructor.
      Parameters:
      type - The type
    • RuntimePersistentEntity

      public RuntimePersistentEntity(io.micronaut.core.beans.BeanIntrospection<T> introspection)
      Default constructor.
      Parameters:
      introspection - The introspection
    • RuntimePersistentEntity

      public RuntimePersistentEntity(io.micronaut.core.beans.BeanIntrospection<T> introspection, Collection<io.micronaut.core.beans.BeanProperty<T,Object>> beanProperties)
      Default constructor.
      Parameters:
      introspection - The introspection
      beanProperties - The bean properties
  • Method Details

    • logDebug

      protected void logDebug(String message, Exception e)
      Description copied from class: AbstractPersistentEntity
      Log error message.
      Overrides:
      logDebug in class AbstractPersistentEntity
      Parameters:
      message - The message
      e - The exception
    • resolveConverter

      protected AttributeConverter<Object,Object> resolveConverter(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

      public String toString()
      Overrides:
      toString in class Object
    • getAliasName

      public String getAliasName()
      Specified by:
      getAliasName in interface PersistentEntity
      Overrides:
      getAliasName in class AbstractPersistentEntity
      Returns:
      A name to use when referring to this element via an alias.
    • getIntrospection

      public io.micronaut.core.beans.BeanIntrospection<T> getIntrospection()
      Returns:
      The underlying introspection.
    • getName

      public String getName()
      Description copied from interface: PersistentEntity
      The entity name including any package prefix.
      Returns:
      The entity name
    • hasCompositeIdentity

      public boolean hasCompositeIdentity()
      Description copied from interface: PersistentEntity
      Has composite identity.
      Returns:
      The true if composite identity present
    • hasIdentity

      public boolean hasIdentity()
      Description copied from interface: PersistentEntity
      Has identity.
      Returns:
      The true if identity present
    • hasVersion

      public boolean hasVersion()
      Description copied from interface: PersistentEntity
      Is the entity versioned for optimistic locking.
      Returns:
      true if versioned
    • getCompositeIdentity

      public RuntimePersistentProperty<T>[] getCompositeIdentity()
      Description copied from interface: PersistentEntity
      The composite id. The method will throw an exception if there is none or one identity. PersistentEntity.hasCompositeIdentity() should be used to check for presence of identity.
      Returns:
      The composite id or null if there isn't one
    • getIdentity

      public RuntimePersistentProperty<T> getIdentity()
      Description copied from interface: PersistentEntity
      Returns the identity of the instance. The method will throw an exception if there is none or more than one identity. PersistentEntity.hasIdentity() should be used to check for presence of identity.
      Returns:
      The identity or null if there isn't one
    • getVersion

      public RuntimePersistentProperty<T> getVersion()
      Description copied from interface: PersistentEntity
      Returns the version property. The method will throw an exception if there is no version property. Use PersistentEntity.hasVersion() to check for presence of version.
      Returns:
      the property
    • getIdentityProperties

      public List<PersistentProperty> getIdentityProperties()
      Description copied from interface: PersistentEntity
      Returns all identity properties.
      Returns:
      The identity properties
    • getRuntimeIdentityProperties

      public List<RuntimePersistentProperty<T>> getRuntimeIdentityProperties()
      An alternative to getIdentityProperties() but that returns RuntimePersistentProperty.
      Returns:
      The identity properties
    • getPersistentProperties

      public Collection<RuntimePersistentProperty<T>> getPersistentProperties()
      Description copied from interface: PersistentEntity
      A list of properties to be persisted.
      Returns:
      A list of PersistentProperty instances
    • getAssociations

      public Collection<RuntimeAssociation<T>> getAssociations()
      Description copied from interface: PersistentEntity
      A list of the associations for this entity. This is typically a subset of the list returned by PersistentEntity.getPersistentProperties()
      Returns:
      A list of associations
    • getPropertyByName

      public @Nullable RuntimePersistentProperty<T> getPropertyByName(String name)
      Description copied from interface: PersistentEntity
      Gets a PersistentProperty instance by name.
      Parameters:
      name - The name of the property
      Returns:
      The PersistentProperty or null if it doesn't exist
    • getPropertyByNameIgnoreCase

      public @Nullable RuntimePersistentProperty<T> getPropertyByNameIgnoreCase(String name)
      Description copied from interface: PersistentEntity
      Gets a PersistentProperty instance by name ignoring the case.
      Parameters:
      name - The name of the property
      Returns:
      The PersistentProperty or null if it doesn't exist
    • getIdentityByName

      public @Nullable RuntimePersistentProperty<T> getIdentityByName(String name)
      Description copied from interface: PersistentEntity
      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

      public List<String> getPersistentPropertyNames()
      Description copied from interface: PersistentEntity
      A list of property names that a persistent.
      Returns:
      A List of strings
    • isOwningEntity

      public boolean isOwningEntity(PersistentEntity owner)
      Description copied from interface: PersistentEntity
      Returns whether the specified entity asserts ownership over this entity.
      Parameters:
      owner - The owning entity
      Returns:
      True if it does own this entity
    • getParentEntity

      public @Nullable PersistentEntity getParentEntity()
      Description copied from interface: PersistentEntity
      Returns the parent entity of this entity.
      Returns:
      The ParentEntity instance
    • getEntity

      protected RuntimePersistentEntity<T> getEntity(Class<T> type)
      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

      public RuntimePersistentProperty<T>[] getConstructorArguments()
      Returns:
      The constructor arguments.
    • hasAutoPopulatedProperties

      public boolean hasAutoPopulatedProperties()
      Returns:
      Returns true if the entity has auto-populated properties.