Jakarta Persistence (JPA) Method

Class<? extends T> getClass(
  T entity
)


Return the concrete entity class if the given entity belonging to the persistence unit and to an open persistence context. This method may, but is not required to, load the given entity by side effect.
Parameters:
entity - entity instance
Returns:
an entity class belonging to the persistence unit.
Throws:
IllegalArgumentException - if the given object is not an instance of an entity class belonging to the persistence unit.
PersistenceException - if the entity is not associated with an open persistence context or cannot be loaded from the database.
Since:
Jakarta Persistence (JPA) 3.2