title: Entity Manager, creating query
body: <p>I have such a two classes:</p>
  
  <pre><code>public class Average {
  long id;
  String name;
  double average;
  public Average(long id , String name , double payment)
  {
      this.id = id;
      this.name = name;
      this.payment = payment;
  }
  
  @Override
  public String toString()
  {
      return id + "\t" + name + " " + payment;
  }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>@Entity
  public class Payment{
  @Id
  @GeneratedValue
  long    id;
  Student student;
  Subject subject;
  double  payment;
  
  public Payment()
  {
  }
  </code></pre>
  
  <p>and I want to perform query on this class with java, but it is not working correctly. What can be wrong. Bellow I posted my query from another class where I call it:</p>
  
  <pre><code>public List&lt;Object&gt; getPayment()
  {
      Query q = entityManager.createQuery("Select NEW Average( g.subject.id , g.subject.name , AVG(g.payment) ) from Payment g GROUP BY g.subject.id, gge.subject.name");
      return q.getResultList();
  }
  </code></pre>
  
  <p>Please be patient with me, this is my first post!</p>