Commit 957accc3 authored by Matija Obreza's avatar Matija Obreza
Browse files

No Hibernate Stateless session

parent 2509c2d8
......@@ -178,12 +178,8 @@ public class DSRowRepositoryCustomImpl implements DSRowCustomRepository {
@Override
public List<Object[]> getRowValues(List<Long> rowIds, Long[] columnDescriptors) {
// LOG.info("Making stateless");
SessionFactory sessionFactory = entityManager.getEntityManagerFactory().unwrap(SessionFactory.class);
StatelessSession session = sessionFactory.openStatelessSession();
Transaction tx = session.beginTransaction();
org.hibernate.Query q = session.createQuery("select dsrv.datasetDescriptor.id, dsrv.row.id, dsrv from DSValue dsrv where dsrv.row.id in (:ids)");
q.setParameterList("ids", rowIds);
Query q = entityManager.createQuery("select dsrv.datasetDescriptor.id, dsrv.row.id, dsrv from DSValue dsrv where dsrv.row.id in (:ids)");
q.setParameter("ids", rowIds);
// LOG.info("Query ready");
// System.out.println("-");
......@@ -192,18 +188,16 @@ public class DSRowRepositoryCustomImpl implements DSRowCustomRepository {
for (int i = 0; i < rowIds.size(); i++) {
results.add(new Object[columnDescriptors.length]);
}
List<Object[]> values = q.getResultList();
// List of [dsd.id, dsrv]
ScrollableResults scroll = q.scroll(ScrollMode.FORWARD_ONLY);
// LOG.info("Scrolling");
int entries = 0;
while (scroll.next()) {
entries++;
Object[] v = scroll.get();
for (Object[] v : values) {
// LOG.info("Got next");
Long dsdId = (Long) v[0];
Long rowId = (Long) v[1];
DSValue<?> dsv = (DSValue<?>) v[2];
entityManager.detach(dsv);
Object[] result = results.get(rowIds.indexOf(rowId));
for (int i = 0; i < columnDescriptors.length; i++) {
if (columnDescriptors[i].equals(dsdId)) {
......@@ -211,10 +205,6 @@ public class DSRowRepositoryCustomImpl implements DSRowCustomRepository {
}
}
}
// LOG.info("Done scrolling entries=" + entries);
tx.commit();
session.close();
// LOG.info("Closing session");
return results;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment