code: public static PolicyLimit findPolicyLimitByUserAndCounter(EntityManager em, PrincipalUser user, PolicyCounter counter) {
          TypedQuery<PolicyLimit> query = em.createNamedQuery("PolicyLimit.findPolicyLimitByUserAndCounter", PolicyLimit.class);
  
          try {
              query.setParameter("user", user);
              query.setParameter("counter", counter);
              return query.getSingleResult();
          } catch (NoResultException ex) {
              return null;
          }
      }
docs: Retrieves the policy limit object for a given user-counter combination.
  
  @param   em       The EntityManager to use.
  @param   user     The user for which to retrieve the policy limit.
  @param   counter  The counter for which to retrieve the policy limit.
  
  @return  The policy limit object for the given user-counter combination. Null if no such record exists.