I'm not able to compare the code (from the logged in professional) with the contracted codigoprofessional (which must be the same as the logged in professional) in the sql query and this causes the query to return a value from another professional.
Here is the code snippet:
FacesContext context = FacesContext.getCurrentInstance();
ELResolver resolver = context.getApplication().getELResolver();
LoginControllerOnline controller = new LoginControllerOnline();
controller = (LoginControllerOnline)
resolver.getValue(context.getELContext(), null, "loginControllerOnline");
pessoa = controller.getPessoa();
if(pessoa instanceof Profissional) {
Profissional profissional = (Profissional) pessoa;
Map<String, Object> params = new HashMap<String, Object>();
String queryArtWeb = "SELECT aw.numeroart, aw.dataElaboracao, p.nome as nomeprofissional, pe.nome as nomeempresa, "
+ "(SELECT nome FROM IdentificacaoContratoArtWeb contrato WHERE contrato.numeroart=aw.numeroart and sequencialcontrato = 1 and sequencialidentificacao = 1) as nomecontratante, "
+ "t.idTipoArt, t.descricao as tipoArt, st.idSubtipoArt, st.descricao as subtipoArt, "
+ "aw.nomeProfissionalContratado, aw.nomeEmpresaContratada "
+ "FROM ArtWeb aw "
+ "LEFT JOIN pessoa p ON p.codigo = aw.codigoprofissionalcontratado "
+ "LEFT JOIN pessoa pe ON pe.codigo = aw.codigoempresacontratada "
+ "LEFT JOIN empresa e ON e.codigo = pe.codigo "
+ "LEFT JOIN TipoArt t ON t.idTipoArt = aw.tipoArt_idTipoArt "
+ "LEFT JOIN SubtipoArt st ON st.idSubtipoArt = aw.subtipoArt_idSubtipoArt "
+ "WHERE aw.codigoprofissionalcontratado = :codigo AND aw.databaixa IS NULL AND datapagamento IS NOT NULL OR valortaxa = 0";
params.put("codigo", profissional.getCodigo());
List<Object[]> registrosArtWeb = objectDao.listPesqQuery(queryArtWeb, params);