Hi we're doing a final project using isis and we get to the part of the queries
and when we tried to make a query that need information of two or more tables
we saw that we can't use for example inner join (sql) so we want to know if
there is any form of doing a join on the query.
We also tried to use object's logic to make this join on this way:
@SuppressWarnings("unlikely-arg-type")
public List<Ficha> findByTecnico(Integer documento) {
List<TecnicoFicha> tecnicoFicha = auxFindByTecnico(documento);
List<Ficha> aux= repositoryService.allMatches(new
QueryDefault<>(Ficha.class, "tecnicoBusqueda"));
List<Ficha> contador=new ArrayList<Ficha>();
for (int k=0; k<aux.size(); k++) {
for(int i=0; i<aux.get(k).getTecnicos().size();i++) {
for(int j=0; j<tecnicoFicha.size();j++) {
if(aux.get(k).getTecnicos().equals(tecnicoFicha.get(j))) {
contador.add(aux.get(k));
}
}
}
}
return contador;
}
private List<TecnicoFicha> auxFindByTecnico(Integer documento){
Tecnico tecnico = repositoryService.uniqueMatch(new
QueryDefault<>(Tecnico.class, "auxTecnico",
"documento", documento));
List<TecnicoFicha> aux = repositoryService.allMatches(new
QueryDefault<>(TecnicoFicha.class,
"auxTecnico2"));
List<TecnicoFicha> contador = new ArrayList<TecnicoFicha>();
for(int i=0; i<aux.size();i++) {
if (aux.get(i).getDocumento().equals(tecnico.getDocumento())){
contador.add(aux.get(i));
}
}
return contador;
}
The private method auxFindByTecnico actually returns a List of TecnicoFicha
we're not having problems there (all queries return all matches of a Class).
The problem is that the Object Ficha contains a List of TecnicoFicha (called
Tecnicos) and we need to return all objets of Ficha where if any of Tecnicos's
object equals any of the tecnicoFicha's object (returned by method
auxFindByTecnico) then add that Ficha on an aux List called contador.
I don't see any problem on my Code i think this should work but when i debug
the App tecnicoFicha has all i need, aux do too but contador don't return
anything.
Thanks for your help.