Galera, estou fazendo uma query dinamica, só que estou recebendo o seguinte erro:
could not locate named parameter [el1]
public List<CorretorPessoa> listaCorretores() {
List<CorretorPessoa> listaCorretores = null;
List<String> queryDinamica = new ArrayList<String>();
if(nomeCorretor != null){
queryDinamica.add("result.pessoa.nomePessoa like '%#{nomeCorretor}%'"); // AQUI ELE É A LINHA PROBLEMÁTICA
}
if(creciCorretor != null && creciCorretor.equalsIgnoreCase("")){
queryDinamica.add("result.corretorCreci = #{creciCorretor}");
}
if(classificacaoSelecionada != null){
queryDinamica.add("result.classificacao = #{classificacaoSelecionada}");
this.setValor(true);
}
try {
EntityQuery<CorretorPessoa> entityQuery = new EntityQuery<CorretorPessoa>();
entityQuery.setEntityManager(entityManager);
entityQuery.setEjbql(" FROM CorretorPessoa result");
entityQuery.setRestrictionExpressionStrings(queryDinamica);
listaCorretores = entityQuery.getResultList();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listaCorretores;
}
Usando somente o like sem ’ e % funciona, só que quando eu coloco dá o erro mencionado acima.