code: public static List<Audit> findByEntity(EntityManager em, JPAEntity entity, BigInteger limit) {
          requireArgument(em != null, "Entity manager cannot be null.");
          requireArgument(entity != null, "Entity cannot be null.");
  
          TypedQuery<Audit> query = em.createNamedQuery("Audit.findByJPAEntity", Audit.class);
  
          if (limit != null) {
              query.setMaxResults(limit.intValue());
          }
          try {
              query.setParameter("jpaEntityId", entity.getId());
              return query.getResultList();
          } catch (NoResultException ex) {
              return new ArrayList<Audit>(0);
          }
      }
docs: Finds all alerts for the given entity.
  
  @param   em      Entity manager. Cannot be null.
  @param   entity  The entity for which all audits will be returned. Cannot be null.
  @param   limit   The number of results to return.
  
  @return  All alerts belongs to given entity.