From 795baa196b492c196007eb8e6b46e7a3bb29d0a2 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Mon, 27 Feb 2023 19:19:09 -0500 Subject: [PATCH] Fix null Tag.userSelected error by defaulting to false if the value is null. (#4605) --- .../4604-tag-definition-boolean-primitive-solution.yaml | 5 +++++ .../java/ca/uhn/fhir/jpa/model/entity/TagDefinition.java | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4604-tag-definition-boolean-primitive-solution.yaml diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4604-tag-definition-boolean-primitive-solution.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4604-tag-definition-boolean-primitive-solution.yaml new file mode 100644 index 00000000000..4e35a797823 --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/6_4_0/4604-tag-definition-boolean-primitive-solution.yaml @@ -0,0 +1,5 @@ +--- +type: fix +issue: 4604 +jira: SMILE-4688 +title: "Doing a GET for a resource tag created before 4204 will return a null error on userSelected. This has been fixed by defaulting null to false." diff --git a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/TagDefinition.java b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/TagDefinition.java index 39a3c52f61b..279622bf0c7 100644 --- a/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/TagDefinition.java +++ b/hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/TagDefinition.java @@ -86,7 +86,7 @@ public class TagDefinition implements Serializable { private String myVersion; @Column(name = "TAG_USER_SELECTED") - private boolean myUserSelected; + private Boolean myUserSelected; @Transient private transient Integer myHashCode; @@ -162,7 +162,11 @@ public class TagDefinition implements Serializable { } } - public Boolean getUserSelected() { return myUserSelected; } + public Boolean getUserSelected() { + // TODO: LD: this is not ideal as we are implicitly assuming null is false. + // Ideally we should fix IBaseCoding to return wrapper Boolean but that will involve another core/hapi release + return myUserSelected != null ? myUserSelected : false; + } public void setUserSelected(Boolean theUserSelected) { myUserSelected = theUserSelected != null && theUserSelected;