title: JPA COUNT with composite primary key query not working
body: <p>In my db, I have a table (Defaults), and when I generate an entity from table, I get these two classes:</p>
  
  <pre><code>@Entity
  public class Defaults implements Serializable {
      private static final long serialVersionUID = 1L;
      @EmbeddedId
      protected DefaultsPK DefaultsPK;
      @Column(name = "ERTEK")
      private String ertek;
  
      getter/setter...
  }
  
  @Embeddable
  public class DefaultsPK implements Serializable {
      @Basic(optional = false)
      @Column(name = "VALUE_1")
      private String value1;
      @Basic(optional = false)
      @Column(name = "TYPE")
      private String type;
      @Basic(optional = false)
      @Column(name = "VALID_FROM")
      @Temporal(TemporalType.TIMESTAMP)
      private Date validFrom;
      @Basic(optional = false)
      @Column(name = "VALID_TO")
      @Temporal(TemporalType.TIMESTAMP)
      private Date validTo;
  
      getter/setter...
  }
  </code></pre>
  
  <p>That is why becaues the primary key is including the values.
  I want to count all the rows in the table, so I use this code:</p>
  
  <pre><code>String sql = "SELECT COUNT(d) FROM Defaults d";
  Query q = em.createQuery(sql);
  long count = (long)q.getSingleResult();
  </code></pre>
  
  <p>But I am getting this error:</p>
  
  <pre><code>org.hibernate.exception.SQLGrammarException: could not execute query
  ...
  java.sql.SQLSyntaxErrorException: ORA-00907: The right expression is missing from the arithmetic expression
  </code></pre>
  
  <p>What is the problem? The other count queries with other entities are working.</p>
  
  <p>I am using hibernate.</p>