private void checkEntityId(Object entityId) { if (entityId == null) { throw new IllegalArgumentException("Invalid null entity id given"); } EntityType<?> entityType = em.getMetamodel() .entity( joinManager .getRootNodeOrFail( "Paginated queries do not support multiple from clause elements!") .getPropertyClass()); Attribute<?, ?> idAttribute = JpaUtils.getIdAttribute(entityType); Class<?> idType = JpaUtils.resolveFieldClass(entityType.getJavaType(), idAttribute); if (!idType.isInstance(entityId)) { throw new IllegalArgumentException( "The type of the given entity id '" + entityId.getClass().getName() + "' is not an instance of the expected id type '" + idType.getName() + "' of the entity class '" + entityType.getJavaType().getName() + "'"); } }