I have such a two classes:
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;
}
}
and
@Entity
public class Payment{
@Id
@GeneratedValue
long id;
Student student;
Subject subject;
double payment;
public Payment()
{
}
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:
public List<Object> 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();
}
Please be patient with me, this is my first post!