Error in Namedquery

Asked

Viewed 66 times

1

Good evening guys, I’m looking to create a namedquery with a bank appointment. Follows:

@NamedQuery(name="ListagemProdutosMesa",query="select Produto p FROM Produto p, Pedido pe, Conta c, Pedido_produto pp  where pe.id = pp.pedido_id and pp.produto_id = p.id and c.id = pe.conta_id and c.id=:idConta")

Where this table Pedido_produto is the table created only to reference foreign keys( I think the problem is there).

The funny thing is query good wheel in the Postgres and in the Java is giving error. Someone could help me???

  • What error? How is your Product table mapped in Java?

  • Friend, thank you for answering. I got it right away. As I was mapping in java I wasn’t thinking like objects, follow the query: @Namedquery(name="Listrequest",query="select pe.product from Request pe, Account c Where c.id = pe.conta.id and c.numeroMesa =:nMesa and c.situacao = false")

  • Put as answer to your own question :)

1 answer

1


I’ve already solved!
As I was mapping in Java I was not thinking like objects, follows the query:

@NamedQuery(name="ListagemPedidoMesa",query="select pe.produto from Pedido pe, Conta c where c.id = pe.conta.id and c.numeroMesa =:nMesa and c.situacao = false") 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.