com.holonplatform.datastore.jpa.jpql.expression

## Interface JpaEntity<T>

- Type Parameters:
    `T` - Entity type
  All Superinterfaces:
    com.holonplatform.core.Expression, Serializable

      public interface JpaEntity<T>
      extends com.holonplatform.core.Expression, Serializable

  JPA entity reference.
  Since:
    5.0.0

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.holonplatform.core.Expression

      `com.holonplatform.core.Expression.ExpressionResolverFunction<E extends com.holonplatform.core.Expression,R extends com.holonplatform.core.Expression>, com.holonplatform.core.Expression.InvalidExpressionException`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `static <T> JpaEntity<T>` | `create(javax.persistence.metamodel.Metamodel metamodel, Class<T> entityClass)` Create a new `JpaEntity` from given `entityClass`.
    `Class<T>` | `getEntityClass()` Get the entity class.
    `String` | `getEntityName()` Get the entity name.
    `Optional<Object>` | `getId(T entity)` Get the id value of given entity istance.
    `Optional<Class<?>>` | `getIdType()` Get the type of the entity id, if available.
    `boolean` | `hasCompositeId()` Get whether the entity has a composite id.
    `boolean` | `isNew(T entity)` Gets whether given entity instance has to be considered new according to entity id value.

    - ### Methods inherited from interface com.holonplatform.core.Expression

      `validate`

- - ### Method Detail

    - #### getEntityClass

          Class<T> getEntityClass()

      Get the entity class.
      Returns:
        the entity class

    - #### getEntityName

          String getEntityName()

      Get the entity name.
      Returns:
        The entity name

    - #### getIdType

          Optional<Class<?>> getIdType()
                                throws IllegalStateException

      Get the type of the entity id, if available.
      Returns:
        the entity id type
      Throws:
        `IllegalStateException` - If the entity identifier metadata are not available

    - #### hasCompositeId

          boolean hasCompositeId()
                          throws IllegalStateException

      Get whether the entity has a composite id.
      Returns:
        `true` if the entity has a composite (multi attribute) id, `false` if the entity has a simple (single attribute) id or if the entity id is not available
      Throws:
        `IllegalStateException` - If the entity identifier metadata are not available

    - #### getId

          Optional<Object> getId(T entity)
                          throws IllegalStateException

      Get the id value of given entity istance.
      Parameters:
        `entity` - Entity istance (not null)
      Returns:
        The id value, if available
      Throws:
        `IllegalStateException` - If the entity identifier metadata are not available

    - #### isNew

          boolean isNew(T entity)
                 throws IllegalStateException

      Gets whether given entity instance has to be considered new according to entity id value.

      When entity id is not available, always returns `false`.

      Parameters:
        `entity` - Entity instance (not null)
      Returns:
        `true` if entity instance has to be considered new, `false` otherwise
      Throws:
        `IllegalStateException` - If the entity identifier metadata are not available

    - #### create

          static <T> JpaEntity<T> create(javax.persistence.metamodel.Metamodel metamodel,
                                         Class<T> entityClass)

      Create a new `JpaEntity` from given `entityClass`.
      Type Parameters:
        `T` - Entity type
      Parameters:
        `metamodel` - JPA Metamodel (not null)
        `entityClass` - Entity class (not null)
      Returns:
        A new `JpaEntity`

Copyright © 2019 The Holon Platform. All rights reserved.