Class JpaMetamodelEntityInformation<T,ID>

All Implemented Interfaces:
JpaEntityMetadata<T>, JpaEntityInformation<T,ID>, EntityInformation<T,ID>, EntityMetadata<T>
Direct Known Subclasses:
JpaPersistableEntityInformation

public class JpaMetamodelEntityInformation<T,ID> extends JpaEntityInformationSupport<T,ID>
Implementation of EntityInformation that uses JPA Metamodel to find the domain class' id field.
Author:
Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch, Jens Schauder, Greg Turnquist
  • Constructor Details

    • JpaMetamodelEntityInformation

      public JpaMetamodelEntityInformation(Class<T> domainClass, jakarta.persistence.metamodel.Metamodel metamodel, jakarta.persistence.PersistenceUnitUtil persistenceUnitUtil)
      Creates a new JpaMetamodelEntityInformation for the given domain class and Metamodel.
      Parameters:
      domainClass - must not be null.
      metamodel - must not be null.
      persistenceUnitUtil - must not be null.
  • Method Details

    • getEntityName

      public String getEntityName()
      Description copied from interface: JpaEntityMetadata
      Returns the name of the entity.
      Specified by:
      getEntityName in interface JpaEntityMetadata<T>
      Overrides:
      getEntityName in class JpaEntityInformationSupport<T,ID>
      Returns:
    • getId

      @Nullable public ID getId(T entity)
    • getIdType

      public Class<ID> getIdType()
    • getIdAttribute

      public jakarta.persistence.metamodel.SingularAttribute<? super T,?> getIdAttribute()
      Description copied from interface: JpaEntityInformation
      Returns the id attribute of the entity.
    • hasCompositeId

      public boolean hasCompositeId()
      Description copied from interface: JpaEntityInformation
      Returns true if the entity has a composite id.
    • getIdAttributeNames

      public Collection<String> getIdAttributeNames()
      Description copied from interface: JpaEntityInformation
      Returns the attribute names of the id attributes. If the entity has a composite id, then all id attribute names are returned. If the entity has a single id attribute then this single attribute name is returned.
    • getCompositeIdAttributeValue

      public Object getCompositeIdAttributeValue(Object id, String idAttribute)
      Description copied from interface: JpaEntityInformation
      Extracts the value for the given id attribute from a composite id
      Parameters:
      id - the composite id from which to extract the attribute.
      idAttribute - the attribute name to extract.
    • isNew

      public boolean isNew(T entity)
      Specified by:
      isNew in interface EntityInformation<T,ID>
      Overrides:
      isNew in class AbstractEntityInformation<T,ID>
    • getKeyset

      public Map<String,Object> getKeyset(Iterable<String> propertyPaths, T entity)
      Description copied from interface: JpaEntityInformation
      Extract a keyset for propertyPaths and the primary key (including composite key components if applicable).
      Parameters:
      propertyPaths - the property paths that make up the keyset in combination with the composite key components.
      entity - the entity to extract values from
      Returns:
      a map mapping String representations of the paths to values from the entity.