JPA Method
in jakarta.persistence.PersistenceUnitUtil

boolean isInstance(
  Object entity, 
  Class<?> entityClass
)


Return true if the given entity belonging to the persistence unit and to an open persistence context is an instance of the given entity class, or false otherwise. This method may, but is not required to, load the given entity by side effect.
Parameters:
entity - entity instance
entityClass - 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 or if the given class is not 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:
JPA 3.2