title: Syntax to query two fields in a table with JPA
body: <p>Referencing <a href="http://docs.oracle.com/javaee/5/tutorial/doc/bnbuf.html" rel="nofollow">JPQL</a>, it's not clear to me exactly how to query a table.</p>
  
  <p>What I want is, if it exists, the <code>@Entity Note</code> for a given messagId and group, but I don't understand the syntax.</p>
  
  <p>How do I specify the messageId and group for the below query?</p>
  
  <pre><code>public void persist(Msg message) {
      LOG.info("\t" + message);
      LOG.info("isOpen?" + em.isOpen());
      em.getTransaction().begin();
      int id = message.getId();
      Query q = em.createQuery("SELECT  n "
              + "FROM Notes n WHERE n.messageId = :messageId "
              + "AND n.group = :group");
      List results = q.getResultList();
      em.getTransaction().commit();
      for (Object o : results) {
          LOG.info("object is \n\n" + o);
      }
  }
  </code></pre>
  
  <p>}</p>