title: Query needed to check if an email already exist in a DB(Java Persistence API)
body: <p>I try to figure out what is the problem with this method that uses JPQL to validate if an email already exist in the DB, for some reason it does not work. Someone can have a look? Or give another alternative query more simple?</p>
  
  <pre><code>@Override
  public boolean emailAlreadyExists(String value) {
      Query checkEmailExists = em.createQuery("SELECT COUNT(b.email) FROM "
              + Buyer.class.getName() + " b WHERE email = :emailparam");
      checkEmailExists.setParameter("emailparam", value);
      long matchCounter = 0;
      matchCounter = (Long) checkEmailExists.getSingleResult();
      if (matchCounter &gt; 0) {
          return true;
      }
      return false;
  }
  </code></pre>
  
  <p>This is part of the console output:</p>
  
  <blockquote>
    <p>Caused by: Exception [EclipseLink-8024] (Eclipse Persistence Services - 2.0.1.v20100213-r6600): org.eclipse.persistence.exceptions.JPQLException
    Exception Description: Syntax error parsing the query [SELECT COUNT(b.email) FROM entities.Buyer b WHERE b.email = :emailparam], line 1, column 35: syntax error at [.].
    Internal Exception: MismatchedTokenException(83!=78)</p>
  </blockquote>
  
  <p>Im sure it has to do something with the syntax. But where i am making the mistake?</p>