diff --git a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java index 21e382df6c..6dfb4379f9 100644 --- a/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java +++ b/mir-module/src/main/java/org/mycore/mir/migration/MIRMigrateStaticHistoryContent.java @@ -51,16 +51,17 @@ public void startUp(ServletContext servletContext) { private boolean alreadyDone() { EntityManager manager = MCREntityManagerProvider.getCurrentEntityManager(); CriteriaBuilder builder = manager.getCriteriaBuilder(); - CriteriaQuery criteria = builder.createQuery(MCRJob.class); + CriteriaQuery criteria = builder.createQuery(Long.class); Root root = criteria.from(MCRJob.class); - List predicates = new ArrayList(); + List predicates = new ArrayList<>(); predicates.add(builder.equal(root.get(MCRJob_.action), MIRMigrateStaticHistoryContentJobAction.class)); predicates.add(builder.equal(root.get(MCRJob_.status), MCRJobStatus.FINISHED)); + criteria.select(builder.count(root)); criteria.where(predicates.toArray(new Predicate[] {})); - List resultList = manager.createQuery(criteria).getResultList(); + Long result = manager.createQuery(criteria).getSingleResult(); - return resultList.size() > 0; + return result > 0; } }