0
I made a select JPQL but I’m having this error:
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: where near line 1, column 151 [select pes, pEnd from digifred.model.global.Pessoas pes, digifred.model.global.PessoasEnderecos pEnd where pes.entidade.idEntidade = :parametroId and where pEnd.entidade.idEntidade=:parametroId]
at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187) ~[hibernate-core-5.0.12.Final.jar:5.0.12.Final]
My method is like this:
@Query( value="select pes, pEnd from Pessoas pes, PessoasEnderecos pEnd where pes.entidade.idEntidade = :parametroId and where pEnd.entidade.idEntidade=:parametroId" )
public Collection<Pessoas> encontrar(@Param("parametroId") Long usuarioEntidade);
you are using spring ?
– alxwca
Yes, I’m using Spring boot
– Eduardo Krakhecke
https://spring.io/blog/2014/07/15/spel-support-in-spring-data-jpa-query-definitions Only the shape of your parameter is wrong : #{#parametroId.identity} : ? #{[parametroId]} For being long
– alxwca
If you can put as an answer there with my code so I can see better..
– Eduardo Krakhecke
You are using HQL syntax, only use JPQL inside your code. Ta run in the trampo, but wait I’ll tidy up
– alxwca