Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

9799 external laboratory workload report caching issue #10130

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3272,7 +3272,7 @@ private ReportTemplateRowBundle generateExternalLaboratoryWorkloadBillItems(List
System.out.println("jpql = " + jpql);
System.out.println("parameters = " + parameters);

List<ReportTemplateRow> rs = (List<ReportTemplateRow>) paymentFacade.findLightsByJpql(jpql, parameters, TemporalType.TIMESTAMP);
List<ReportTemplateRow> rs = (List<ReportTemplateRow>) paymentFacade.findLightsByJpqlWithoutCache(jpql, parameters, TemporalType.TIMESTAMP);

ReportTemplateRowBundle b = new ReportTemplateRowBundle();
b.setReportTemplateRows(rs);
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/divudi/facade/AbstractFacade.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,34 @@ public List<?> findLightsByJpql(String jpql, Map<String, Object> parameters, Tem
return resultList;
}

public List<?> findLightsByJpqlWithoutCache(String jpql, Map<String, Object> parameters, TemporalType tt) {
Query qry = getEntityManager().createQuery(jpql);

qry.setHint("javax.persistence.cache.storeMode", "REFRESH");

Set<Map.Entry<String, Object>> entries = parameters.entrySet();

for (Map.Entry<String, Object> entry : entries) {
String paramName = entry.getKey();
Object paramValue = entry.getValue();

if (paramValue instanceof Date) {
qry.setParameter(paramName, (Date) paramValue, tt);
} else {
qry.setParameter(paramName, paramValue);
}
}

List<?> resultList;
try {
resultList = qry.getResultList();
} catch (Exception e) {
resultList = new ArrayList<>();
}

return resultList;
}

public List<?> findLightsByJpql(String jpql, Map<String, Object> parameters, TemporalType tt, int maxRecords) {
Query qry = getEntityManager().createQuery(jpql);
Set<Map.Entry<String, Object>> entries = parameters.entrySet();
Expand Down