I have the following packages and classes.
When I'm going to do this JPA query, I need to pass all the class's fully qualified name (as it's in the example) because JPA can not find it if I just pass its name, no matter the class works.
Is there any way to solve this problem? Because I have to migrate some packages here in the project and will break about 20 queries and would have to go in each class and change manually.
br.com.projeto.dao.VendaDAO
br.com.projeto.model.Venda
br.com.projeto.model.VendaTotal
class VendaDao{
public List<VendaTotal> getTotaisDeVentas(){
String jpql =
"select new br.com.projeto.model.VendaTotal(sum v.valor) " +
"from Venda v " +
"group by v.data";
return entityManager.createQuery(jpql, VentaTotal.class).getResultList();
}
}
class Venda{
private Double valor;
private Date data;
// getters e setters
}
class VendaTotal{
private Double valor;
public VentaTotal(Double valor){
this.valor = valor;
}
// getters e setters
}