Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
9270afe410
|
@ -119,9 +119,10 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
TagDefinition def = getTagOrNull(TagTypeEnum.TAG, theScheme, theTerm, theLabel);
|
||||
if (def != null) {
|
||||
BaseTag newEntity = entity.addTag(def);
|
||||
|
||||
myEntityManager.persist(newEntity);
|
||||
myEntityManager.merge(entity);
|
||||
if (newEntity.getTagId() == null) {
|
||||
myEntityManager.persist(newEntity);
|
||||
myEntityManager.merge(entity);
|
||||
}
|
||||
}
|
||||
|
||||
ourLog.info("Processed addTag {}/{} on {} in {}ms", new Object[] { theScheme, theTerm, theId, w.getMillisAndRestart() });
|
||||
|
@ -450,7 +451,9 @@ public abstract class BaseHapiFhirResourceDao<T extends IBaseResource> extends B
|
|||
TagDefinition def = getTagOrNull(nextDef.getTagType(), nextDef.getSystem(), nextDef.getCode(), nextDef.getDisplay());
|
||||
if (def != null) {
|
||||
BaseTag newEntity = entity.addTag(def);
|
||||
myEntityManager.persist(newEntity);
|
||||
if (newEntity.getTagId() == null) {
|
||||
myEntityManager.persist(newEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,16 +23,7 @@ package ca.uhn.fhir.jpa.entity;
|
|||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.Lob;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import javax.persistence.OneToOne;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.*;
|
||||
|
||||
import ca.uhn.fhir.context.FhirVersionEnum;
|
||||
import ca.uhn.fhir.model.primitive.IdDt;
|
||||
|
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.jpa.entity;
|
|||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -32,13 +32,17 @@ public class BaseTag implements Serializable {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ManyToOne(cascade= {})
|
||||
@JoinColumn(name="TAG_ID", nullable=false)
|
||||
@ManyToOne(cascade = {})
|
||||
@JoinColumn(name = "TAG_ID", nullable = false)
|
||||
private TagDefinition myTag;
|
||||
|
||||
@Column(name="TAG_ID", insertable=false,updatable=false)
|
||||
@Column(name = "TAG_ID", insertable = false, updatable = false)
|
||||
private Long myTagId;
|
||||
|
||||
public Long getTagId() {
|
||||
return myTagId;
|
||||
}
|
||||
|
||||
public TagDefinition getTag() {
|
||||
return myTag;
|
||||
}
|
||||
|
@ -46,6 +50,5 @@ public class BaseTag implements Serializable {
|
|||
public void setTag(TagDefinition theTag) {
|
||||
myTag = theTag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -93,8 +93,13 @@ public class ResourceHistoryTable extends BaseHasResource implements Serializabl
|
|||
}
|
||||
|
||||
@Override
|
||||
public BaseTag addTag(TagDefinition theDef) {
|
||||
ResourceHistoryTag historyTag = new ResourceHistoryTag(this, theDef);
|
||||
public ResourceHistoryTag addTag(TagDefinition theTag) {
|
||||
for (ResourceHistoryTag next : getTags()) {
|
||||
if (next.getTag().equals(theTag)) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
ResourceHistoryTag historyTag = new ResourceHistoryTag(this, theTag);
|
||||
getTags().add(historyTag);
|
||||
return historyTag;
|
||||
}
|
||||
|
|
|
@ -250,10 +250,13 @@ public class ResourceTable extends BaseHasResource implements Serializable {
|
|||
|
||||
@Override
|
||||
public ResourceTag addTag(TagDefinition theTag) {
|
||||
ResourceTag tag = new ResourceTag(this, theTag);
|
||||
if (!getTags().contains(tag)) {
|
||||
getTags().add(tag);
|
||||
for (ResourceTag next : getTags()) {
|
||||
if (next.getTag().equals(theTag)) {
|
||||
return next;
|
||||
}
|
||||
}
|
||||
ResourceTag tag = new ResourceTag(this, theTag);
|
||||
getTags().add(tag);
|
||||
return tag;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ package ca.uhn.fhir.jpa.entity;
|
|||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
|
@ -45,8 +45,8 @@ import ca.uhn.fhir.model.api.Tag;
|
|||
|
||||
//@formatter:on
|
||||
@Entity
|
||||
@Table(name = "HFJ_TAG_DEF", uniqueConstraints = {
|
||||
@UniqueConstraint(name="IDX_TAGDEF_TYPESYSCODE", columnNames = { "TAG_TYPE", "TAG_SYSTEM", "TAG_CODE" })
|
||||
@Table(name = "HFJ_TAG_DEF", uniqueConstraints = {
|
||||
@UniqueConstraint(name = "IDX_TAGDEF_TYPESYSCODE", columnNames = { "TAG_TYPE", "TAG_SYSTEM", "TAG_CODE" })
|
||||
})
|
||||
//@formatter:off
|
||||
public class TagDefinition implements Serializable {
|
||||
|
@ -78,6 +78,8 @@ public class TagDefinition implements Serializable {
|
|||
@Enumerated(EnumType.ORDINAL)
|
||||
private TagTypeEnum myTagType;
|
||||
|
||||
private Integer myHashCode;
|
||||
|
||||
public TagDefinition() {
|
||||
}
|
||||
|
||||
|
@ -110,6 +112,7 @@ public class TagDefinition implements Serializable {
|
|||
|
||||
public void setCode(String theCode) {
|
||||
myCode = theCode;
|
||||
myHashCode = null;
|
||||
}
|
||||
|
||||
public void setDisplay(String theDisplay) {
|
||||
|
@ -118,10 +121,12 @@ public class TagDefinition implements Serializable {
|
|||
|
||||
public void setSystem(String theSystem) {
|
||||
mySystem = theSystem;
|
||||
myHashCode = null;
|
||||
}
|
||||
|
||||
public void setTagType(TagTypeEnum theTagType) {
|
||||
myTagType = theTagType;
|
||||
myHashCode = null;
|
||||
}
|
||||
|
||||
public Tag toTag() {
|
||||
|
@ -155,15 +160,14 @@ public class TagDefinition implements Serializable {
|
|||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder b = new HashCodeBuilder();
|
||||
if (myId != null) {
|
||||
b.append(myId);
|
||||
} else {
|
||||
if (myHashCode == null) {
|
||||
HashCodeBuilder b = new HashCodeBuilder();
|
||||
b.append(myTagType);
|
||||
b.append(mySystem);
|
||||
b.append(myCode);
|
||||
myHashCode = b.toHashCode();
|
||||
}
|
||||
return b.toHashCode();
|
||||
return myHashCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,7 +100,8 @@
|
|||
</action>
|
||||
<action type="fix">
|
||||
Fix a regression in HAPI FHIR 2.5 JPA server where executing a search in a
|
||||
transaction or batch operation caused an exception.
|
||||
transaction or batch operation caused an exception. Thanks to Ravi Kuchi for
|
||||
reporting!
|
||||
</action>
|
||||
<action type="fix">
|
||||
Correct an issue when processing transactions in JPA server where updates and
|
||||
|
|
Loading…
Reference in New Issue