code: public static <E extends Identifiable> E findByPrimaryKey(EntityManager em, BigInteger id, Class<E> type) {
          requireArgument(em != null, "The entity manager cannot be null.");
          requireArgument(id != null && id.compareTo(ZERO) > 0, "ID cannot be null and must be positive and non-zero");
          requireArgument(type != null, "The entity type cannot be null.");
  
          TypedQuery<E> query = em.createNamedQuery("JPAEntity.findByPrimaryKey", type);
  
          query.setHint("javax.persistence.cache.storeMode", "REFRESH");
          try {
              query.setParameter("id", id);
              query.setParameter("deleted", false);
              return query.getSingleResult();
          } catch (NoResultException ex) {
              return null;
          }
      }
docs: Finds a JPA entity by its primary key.
  
  @param   <E>   The JPA entity type.
  @param   em    The entity manager to use.  Cannot be null.
  @param   id    The ID of the entity to find.  Must be a positive, non-zero integer.
  @param   type  The runtime type to cast the result value to.
  
  @return  The corresponding entity or null if no entity exists.