Criteria throwing Java heap space due to the size of the Restrictions.in () clause

0

I am trying to run a query using Criteria but it is returning an Exception from "Java heap". It should probably be the amount of data I'm passing in the "in" clauses

Here is a code that represents my query:

Criteria c = session.createCriteria(Classe1.class, "C1");
c.createAlias("C1.itens", "Itens");
c.createAlias("Itens.nros", "Nros");
c.createAlias("Itens.estados", "Estados");
c.createAlias("C1.janelas", "Janelas");
c.createAlias("C1.criador", "Criador");
c.createAlias("C1.xamines", "Xamines");
c.createAlias("C1.torres", "Torres");
c.add(Restrictions.in("Nros.id", "lista com aprox 40 registros"));
c.add(Restrictions.in("Estados.id", "lista com aprox 5000 registros"));
c.add(Restrictions.in("Criador.id", "lista com aprox 1500 registros"));
c.add(Restrictions.in("Xamines.id", "lista com aprox 50 registros"));
c.add(Restrictions.in("Torres.id", "lista com aprox 50 registros"))
        .addOrder(Order.asc("C1.id"));
c.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
long tempoFinal = System.currentTimeMillis();
List<Classe1> listass=c.list();

I do not understand almost anything about Criteria, so I wonder if there is a "Best" way to run this query.

ps: When decreasing the size of the lists passed in the "IN" clauses to a small size, the "Java Heap" error does not occur.

Usually each C1 has 3 to 4 "Items" each Item only 1 "No".

    
asked by anonymous 22.03.2018 / 16:38

0 answers