Eclipse / Java
I have a method to perform database query.
myBean :
List<Composicao> itemProdutoLista = compPrecoServico.buscar(Composicao.nomeQuery);
The nomeQuery is :
@NamedQuery(name = "nomeQuery", query= " SELECT composicao.valortotal,composicao.id FROM Composicao composicao
query - javax.persistence.query
public List<T> buscar(String nomeQuery) {
Query query = entityManager.createNamedQuery(nomeQuery);
return query.getResultList();
}
My return List buscar get me that : An Object elementData

How can I get an Entity Composicao elementdata in my return buscar method ? instead of object elementData
List<Composicao> itemProdutoListacontains objects of typeComposicaoso which part of your code is incorrect?itemProdutoListayou getObject? But your list is already correctly typed, so when the type would not match, you would get aClassCastExceptionmost likely.