spotless
This commit is contained in:
parent
6958f0eb43
commit
a944c18a38
|
@ -199,28 +199,24 @@ public abstract class BaseHapiFhirSystemDao<T extends IBaseBundle, MT> extends B
|
||||||
if (ids.size() >= 2) {
|
if (ids.size() >= 2) {
|
||||||
List<ResourceTable> loadedResourceTableEntries = new ArrayList<>();
|
List<ResourceTable> loadedResourceTableEntries = new ArrayList<>();
|
||||||
|
|
||||||
new QueryChunker<Long>()
|
new QueryChunker<Long>().chunk(ids, nextChunk -> {
|
||||||
.chunk(
|
// List<ResourceTable> allById = myResourceTableDao.findAllById(nextChunk);
|
||||||
ids,
|
Query query = myEntityManager.createQuery("select r, h FROM ResourceTable r "
|
||||||
nextChunk -> {
|
+ " LEFT JOIN fetch ResourceHistoryTable h on r.myVersion = h.myResourceVersion and r.id = h.myResourceId"
|
||||||
//List<ResourceTable> allById = myResourceTableDao.findAllById(nextChunk);
|
+ " left join fetch h.myProvenance"
|
||||||
Query query = myEntityManager.createQuery(
|
+ " WHERE r.myId IN ( :IDS )");
|
||||||
"select r, h FROM ResourceTable r " +
|
query.setParameter("IDS", ids);
|
||||||
" LEFT JOIN fetch ResourceHistoryTable h on r.myVersion = h.myResourceVersion and r.id = h.myResourceId" +
|
|
||||||
" left join fetch h.myProvenance" +
|
|
||||||
" WHERE r.myId IN ( :IDS )");
|
|
||||||
query.setParameter("IDS", ids);
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<Object[]> allById = query.getResultList();
|
List<Object[]> allById = query.getResultList();
|
||||||
|
|
||||||
for (Object[] nextPair : allById) {
|
for (Object[] nextPair : allById) {
|
||||||
ResourceTable r = (ResourceTable) nextPair[0];
|
ResourceTable r = (ResourceTable) nextPair[0];
|
||||||
ResourceHistoryTable h = (ResourceHistoryTable) nextPair[1];
|
ResourceHistoryTable h = (ResourceHistoryTable) nextPair[1];
|
||||||
r.setCurrentVersionEntity(h);
|
r.setCurrentVersionEntity(h);
|
||||||
loadedResourceTableEntries.add(r);
|
loadedResourceTableEntries.add(r);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
List<Long> entityIds;
|
List<Long> entityIds;
|
||||||
|
|
||||||
|
@ -282,33 +278,33 @@ public abstract class BaseHapiFhirSystemDao<T extends IBaseBundle, MT> extends B
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// new QueryChunker<ResourceTable>()
|
// new QueryChunker<ResourceTable>()
|
||||||
// .chunk(loadedResourceTableEntries, SearchBuilder.getMaximumPageSize() / 2, entries -> {
|
// .chunk(loadedResourceTableEntries, SearchBuilder.getMaximumPageSize() / 2, entries -> {
|
||||||
// Map<Long, ResourceTable> entities =
|
// Map<Long, ResourceTable> entities =
|
||||||
// entries.stream().collect(Collectors.toMap(ResourceTable::getId, t -> t));
|
// entries.stream().collect(Collectors.toMap(ResourceTable::getId, t -> t));
|
||||||
//
|
//
|
||||||
// CriteriaBuilder b = myEntityManager.getCriteriaBuilder();
|
// CriteriaBuilder b = myEntityManager.getCriteriaBuilder();
|
||||||
// CriteriaQuery<ResourceHistoryTable> q = b.createQuery(ResourceHistoryTable.class);
|
// CriteriaQuery<ResourceHistoryTable> q = b.createQuery(ResourceHistoryTable.class);
|
||||||
// Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
// Root<ResourceHistoryTable> from = q.from(ResourceHistoryTable.class);
|
||||||
//
|
//
|
||||||
// from.fetch("myProvenance", JoinType.LEFT);
|
// from.fetch("myProvenance", JoinType.LEFT);
|
||||||
//
|
//
|
||||||
// List<Predicate> orPredicates = new ArrayList<>();
|
// List<Predicate> orPredicates = new ArrayList<>();
|
||||||
// for (ResourceTable next : entries) {
|
// for (ResourceTable next : entries) {
|
||||||
// Predicate resId = b.equal(from.get("myResourceId"), next.getId());
|
// Predicate resId = b.equal(from.get("myResourceId"), next.getId());
|
||||||
// Predicate resVer = b.equal(from.get("myResourceVersion"), next.getVersion());
|
// Predicate resVer = b.equal(from.get("myResourceVersion"), next.getVersion());
|
||||||
// orPredicates.add(b.and(resId, resVer));
|
// orPredicates.add(b.and(resId, resVer));
|
||||||
// }
|
// }
|
||||||
// q.where(b.or(orPredicates.toArray(EMPTY_PREDICATE_ARRAY)));
|
// q.where(b.or(orPredicates.toArray(EMPTY_PREDICATE_ARRAY)));
|
||||||
// List<ResourceHistoryTable> resultList =
|
// List<ResourceHistoryTable> resultList =
|
||||||
// myEntityManager.createQuery(q).getResultList();
|
// myEntityManager.createQuery(q).getResultList();
|
||||||
// for (ResourceHistoryTable next : resultList) {
|
// for (ResourceHistoryTable next : resultList) {
|
||||||
// ResourceTable nextEntity = entities.get(next.getResourceId());
|
// ResourceTable nextEntity = entities.get(next.getResourceId());
|
||||||
// if (nextEntity != null) {
|
// if (nextEntity != null) {
|
||||||
// nextEntity.setCurrentVersionEntity(next);
|
// nextEntity.setCurrentVersionEntity(next);
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue