Completing the response of the escapiston, it is possible to do, and it is practically what he already said in his answer:
Assuming your User class is in the following package: br.com.myour system.entities.
Here you can make jpql like this:
SELECT new br.com.meusistema.entidades.Usuario(u.nome, u.sobrenome, u.email) from Usuario u
Notice the new and path of the class.
And it would be necessary to add a matching constructor in the User class:
public class Usuario {
private Integer id;
private Email email;
private String nome;
private String sobrenome;
private String senha;
private String usuario;
private List<Grupo> grupos;
//construtor padrão
public Usuario(){}
//construtor corresponde a busca
public Usuario(String nome, String sobrenome, String email){
this.nome = nome;
this.sobrenome = sobrenome;
this.email = email;
}
//getters e setters
}
In short: you need a constructor with the attributes you are looking for in select, and add new and class path in JPQL , so you could get a List as a query return, because for each row of the table will be instantiated an object using the constructor that corresponds to the attributes of the query, if you do not have a corresponding constructor, an exception will be bound by saying that there is no appropriate constructor.