Excessive Hibernate warnings when processing conditional create and delete operations on referenced resources in a transaction bundle - fix
This commit is contained in:
parent
a4a1f09c21
commit
0a2bd027e4
|
@ -31,6 +31,7 @@ import jakarta.persistence.Id;
|
||||||
import jakarta.persistence.Index;
|
import jakarta.persistence.Index;
|
||||||
import jakarta.persistence.JoinColumn;
|
import jakarta.persistence.JoinColumn;
|
||||||
import jakarta.persistence.ManyToOne;
|
import jakarta.persistence.ManyToOne;
|
||||||
|
import jakarta.persistence.PostLoad;
|
||||||
import jakarta.persistence.Table;
|
import jakarta.persistence.Table;
|
||||||
import jakarta.persistence.Temporal;
|
import jakarta.persistence.Temporal;
|
||||||
import jakarta.persistence.TemporalType;
|
import jakarta.persistence.TemporalType;
|
||||||
|
@ -97,6 +98,9 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
foreignKey = @ForeignKey(name = "FK_RESLINK_TARGET"))
|
foreignKey = @ForeignKey(name = "FK_RESLINK_TARGET"))
|
||||||
private ResourceTable myTargetResource;
|
private ResourceTable myTargetResource;
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private ResourceTable myTransientTargetResource;
|
||||||
|
|
||||||
@Column(name = "TARGET_RESOURCE_ID", insertable = true, updatable = true, nullable = true)
|
@Column(name = "TARGET_RESOURCE_ID", insertable = true, updatable = true, nullable = true)
|
||||||
@FullTextField
|
@FullTextField
|
||||||
private Long myTargetResourcePid;
|
private Long myTargetResourcePid;
|
||||||
|
@ -141,7 +145,7 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTargetResourceId() {
|
public String getTargetResourceId() {
|
||||||
if (myTargetResourceId == null && myTargetResource != null) {
|
if (myTargetResourceId == null && getTargetResource() != null) {
|
||||||
myTargetResourceId = getTargetResource().getIdDt().getIdPart();
|
myTargetResourceId = getTargetResource().getIdDt().getIdPart();
|
||||||
}
|
}
|
||||||
return myTargetResourceId;
|
return myTargetResourceId;
|
||||||
|
@ -184,11 +188,21 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
return b.isEquals();
|
return b.isEquals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ResourceLink.myTargetResource field is immutable.Transient ResourceLink.myTransientTargetResource property
|
||||||
|
* is used instead, allowing it to be updated via the ResourceLink#copyMutableValuesFrom method
|
||||||
|
* when ResourceLink table row is reused.
|
||||||
|
*/
|
||||||
|
@PostLoad
|
||||||
|
public void postLoad() {
|
||||||
|
myTransientTargetResource = myTargetResource;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends BaseResourceIndex> void copyMutableValuesFrom(T theSource) {
|
public <T extends BaseResourceIndex> void copyMutableValuesFrom(T theSource) {
|
||||||
ResourceLink source = (ResourceLink) theSource;
|
ResourceLink source = (ResourceLink) theSource;
|
||||||
mySourcePath = source.getSourcePath();
|
mySourcePath = source.getSourcePath();
|
||||||
myTargetResource = source.getTargetResource();
|
myTransientTargetResource = source.getTargetResource();
|
||||||
myTargetResourceId = source.getTargetResourceId();
|
myTargetResourceId = source.getTargetResourceId();
|
||||||
myTargetResourcePid = source.getTargetResourcePid();
|
myTargetResourcePid = source.getTargetResourcePid();
|
||||||
myTargetResourceType = source.getTargetResourceType();
|
myTargetResourceType = source.getTargetResourceType();
|
||||||
|
@ -331,7 +345,7 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResourceTable getTargetResource() {
|
public ResourceTable getTargetResource() {
|
||||||
return myTargetResource;
|
return myTransientTargetResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -348,8 +362,8 @@ public class ResourceLink extends BaseResourceIndex {
|
||||||
retVal.myTargetResourceType = myTargetResourceType;
|
retVal.myTargetResourceType = myTargetResourceType;
|
||||||
if (myTargetResourceId != null) {
|
if (myTargetResourceId != null) {
|
||||||
retVal.myTargetResourceId = myTargetResourceId;
|
retVal.myTargetResourceId = myTargetResourceId;
|
||||||
} else if (myTargetResource != null) {
|
} else if (getTargetResource() != null) {
|
||||||
retVal.myTargetResourceId = myTargetResource.getIdDt().getIdPart();
|
retVal.myTargetResourceId = getTargetResource().getIdDt().getIdPart();
|
||||||
}
|
}
|
||||||
retVal.myTargetResourceUrl = myTargetResourceUrl;
|
retVal.myTargetResourceUrl = myTargetResourceUrl;
|
||||||
retVal.myTargetResourceVersion = myTargetResourceVersion;
|
retVal.myTargetResourceVersion = myTargetResourceVersion;
|
||||||
|
|
Loading…
Reference in New Issue