From 486903b1f13987000fe374d81d534994175816b1 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Wed, 1 May 2024 14:05:52 -0400 Subject: [PATCH] Fix BaseHapiFhirResourceDao $meta method to use HapiTransactionService instead of @Transaction (#5896) * Try making ResourceTable.myTags EAGER instead of LAZY and see if it breaks anything. * Try making ResourceTable.myTags EAGER instead of LAZY and see if it breaks anything. * Ensure BaseHapiFhirResourceDao#metaGetOperation uses HapiTransactionService instead of @Transactional in order to resolve megascale $meta bug. * Add changelog. * Update hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5898-ld-megascale-meta-operation-fails-hapi-0389.yaml Commit code reviewer suggestion. Co-authored-by: Tadgh --------- Co-authored-by: Tadgh --- ...ascale-meta-operation-fails-hapi-0389.yaml | 5 +++++ .../fhir/jpa/dao/BaseHapiFhirResourceDao.java | 21 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5898-ld-megascale-meta-operation-fails-hapi-0389.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5898-ld-megascale-meta-operation-fails-hapi-0389.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5898-ld-megascale-meta-operation-fails-hapi-0389.yaml new file mode 100644 index 000000000000..dfe2f4595150 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/7_2_0/5898-ld-megascale-meta-operation-fails-hapi-0389.yaml @@ -0,0 +1,5 @@ +--- +type: fix +issue: 5898 +title: "Previously, triggering a `$meta` via GET on a new patient with Megascale configured resulted in error HAPI-0389. This has been corrected + This has been fixed." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java index 686667b28137..1e786ad50704 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/BaseHapiFhirResourceDao.java @@ -1410,19 +1410,20 @@ public MT metaDeleteOperation( } @Override - @Transactional public MT metaGetOperation(Class theType, IIdType theId, RequestDetails theRequest) { - Set tagDefs = new HashSet<>(); - BaseHasResource entity = readEntity(theId, theRequest); - for (BaseTag next : entity.getTags()) { - tagDefs.add(next.getTag()); - } - MT retVal = toMetaDt(theType, tagDefs); + return myTransactionService.withRequest(theRequest).execute(() -> { + Set tagDefs = new HashSet<>(); + BaseHasResource entity = readEntity(theId, theRequest); + for (BaseTag next : entity.getTags()) { + tagDefs.add(next.getTag()); + } + MT retVal = toMetaDt(theType, tagDefs); - retVal.setLastUpdated(entity.getUpdatedDate()); - retVal.setVersionId(Long.toString(entity.getVersion())); + retVal.setLastUpdated(entity.getUpdatedDate()); + retVal.setVersionId(Long.toString(entity.getVersion())); - return retVal; + return retVal; + }); } @Override