Skip to content

Commit

Permalink
Performance improvement for the findToExport query
Browse files Browse the repository at this point in the history
  • Loading branch information
GenieTim committed Dec 31, 2023
1 parent f74945d commit d5e750c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public abstract class GenericLifeCycle<T> {

private final Class<T> tCLass;
private final String idProperty;
protected final String idProperty;
protected Logger log;
boolean anon = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,6 @@ public List<Specimen> findAllPage(int startAt, int fetchSize) {
public List<Specimen> findToExport() {
try {
Session session = this.getSession();
List<Specimen> results = null;
try {
session.beginTransaction();
CriteriaBuilder cb = (CriteriaBuilder) session.getCriteriaBuilder();
Expand All @@ -477,8 +476,11 @@ public List<Specimen> findToExport() {
propertyValueRelations.add(cb.equal(root.get("nahimaExported"), false));
propertyValueRelations.add(cb.lessThan(root.get("dateLastNahimaUpdated"), root.get("dateLastUpdated")));
cr.where(cb.or(propertyValueRelations.toArray(new Predicate[propertyValueRelations.size()])));
Query<Specimen> q = session.createQuery(cr);
results = q.list();
cr.select(root.get(this.idProperty));
Query q = session.createQuery(cr);
List<Long> ids = q.list();
session.getTransaction().commit();
return this.findByIds(ids);
} catch (HibernateException e) {
session.getTransaction().rollback();
log.error("find images failed", e);
Expand All @@ -487,11 +489,11 @@ public List<Specimen> findToExport() {
session.close();
} catch (SessionException e) {
}
return results;
} catch (RuntimeException e) {
log.error("Find to export failed", e);
throw e;
}
return null;
}

// Select distinct path from ICImage im WHERE im.path is not null ORDER BY
Expand Down

0 comments on commit d5e750c

Please sign in to comment.