Estou tendo oq parecer ser um stackoverflow quando tento fazer a query usando uma conta com id 2 como parâmetro. Quando não usei o parâmetro, a query funcinou. Alguém teve um erro parecido? Ainda hoje posto o código.
Você está vendo a versão anterior da nova experiência da Alura que estamos preparando para você. Em breve, ela ganha uma identidade visual novinha totalmente pensada em potencializar seus estudos!
Estou tendo oq parecer ser um stackoverflow quando tento fazer a query usando uma conta com id 2 como parâmetro. Quando não usei o parâmetro, a query funcinou. Alguém teve um erro parecido? Ainda hoje posto o código.
//Vou fazer uma query de todas as movimentacoes de uma determinada conta
Conta conta = new Conta();
conta.setId(2);
//Vou usar um Nomed Parameter pra passar a conta na query, parecido como se faz no JDBC.
//Para indicar um parametro, precisa por :nomeDoParemetro
//O legal e que podemos comparar objetos, entao vou passar a conta direto e nao algum atributo que a identifique.
//Alem disso, nao preciso dizer a coluna da tabela que esta a conta, posso informar como atributo de movimentacao,
//que vou chamar de "m" .
//String jpql = "select m from Movimentacao m where m.conta = :pConta";
String jpql = "select m from Movimentacao m where m.conta = :pConta";
Query query = em.createQuery(jpql);
//Passando a conta
query.setParameter("pConta",conta);
//ERRO DE STACKOVERFLOW AO PASSAR A CONTA COMO PARAMETRO
//Pegando o resultado
List<Movimentacao> resultado = query.getResultList();
System.out.println("MOVIMENTACOES DA CONTA " + resultado.get(0).getConta().getNumero() );
System.out.println("Titular da conta " + resultado.get(0).getConta().getTitular() );
for (Movimentacao movimentacao : resultado) {
System.out.println(movimentacao.getDescricao());
System.out.println(movimentacao.getValor());
System.out.println();
}
Posta a stack do erro aqui, por favor
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
at org.hibernate.metamodel.mapping.EntityValuedModelPart.getJdbcTypeCount(EntityValuedModelPart.java:63)
.
.
.
Tenho esta linha repetida tantas vezes no console que estourei o limite de caracteres quando tentei postar direto aqui. Mas não aparece a mensagem dizendo que deu um stackoverflow, embora eu tenho ido até o topo do console, só essas linhas. Por isso estou muito confuso.