0
I am trying to run a query using Criteria but it is returning a "Java heap" Exception. It’s probably because of the amount of data I’m going through in the "in"
here below 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 understand almost nothing of Criteria, so I would like to know if there is a "Better" way to execute this query.
ps: when I decrease the size of the lists passed in the "IN" clauses to a small size, there is no "Java Heap" error".
Usually each C1 has 3 to 4 "Items" each Item only 1"".
How many records exist on
C1
?– Victor Stafusa
Approximately 25 thousand
– Vinicius Silva
How many states and how many states
C1
has on average?– Victor Stafusa
do not exceed 5 in all relationships
– Vinicius Silva