You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Andi Huber <ah...@apache.org> on 2018/12/02 07:37:46 UTC

Re: Problem with join or compairing the content on a List that contains a List with another List

I can only give you some hints for tracking down the issue here:

1) Be aware of JDO's fetchgroups [1]
2) Be aware, that your domain object's do behave in unpredictable ways once they get detached from the persistence layer. Make sure you do your data processing within a transaction's life-cycle.

If you think, you discovered a bug with JDO (Datanucleus) or Apache Isis, it would help if you could setup some example eg. at github for us to reproduce the issue.

Cheers, Andi

[1] http://www.datanucleus.org/products/accessplatform_4_2/jdo/fetchgroup.html

On 2018/11/28 01:02:58, chidii.nqn@live.com.ar <ch...@live.com.ar> wrote: 
> 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.
> 
>