Galera, estou com um problema em consulta. Ela é basicamente assim:
private static final String[] RESTRICTIONS_WITH = {
" upper(e.razaoSocial) like upper(concat(#{empresa.razaoSocial}, ‘%’))",
" e.uf.nome = #{empresa.uf.nome}",
" e.cidade.nome = #{empresa.cidade.nome}",
" <a href="http://e.categoria.id">e.categoria.id</a> = #{<a href="http://empresa.categoria.id">empresa.categoria.id</a>}",
" <a href="http://s.id">s.id</a> in (#{empresa.subCategorias}) "};
public List buscarEmpresas(Empresa empresa) {
List emps = new ArrayList();
EntityQuery entityQuery = new EntityQuery();
if (empresa.getSubCategorias().isEmpty()) {
entityQuery.setEjbql("select e from Empresa e");
entityQuery.setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
} else {
entityQuery.setEjbql("select distinct (e) from Empresa e inner join e.subCategorias s");
entityQuery.setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS_WITH));
}
entityQuery.setOrder("e.razaoSocial");
emps = entityQuery.getResultList();
return emps;
}
16:56:40,919 INFO [LongType] could not bind value ‘com.organiza.entity.SubCategoria@20’ to parameter: 3; com.organiza.entity.SubCategoria cannot be cast to java.lang.Long
16:56:40,922 ERROR [application] java.lang.ClassCastException: com.organiza.entity.SubCategoria cannot be cast to java.lang.Long
javax.faces.el.EvaluationException: java.lang.ClassCastException: com.organiza.entity.SubCategoria cannot be cast to java.lang.Long