Fix spring transaction issue in getNodetemplates
changes on the db service template object gets auto updated to the db
by spring transaction. Creating new object copy to avoid the same.
Issue-ID: POLICY-3934
Signed-off-by: zrrmmua <ramesh.murugan.iyer@est.tech>
Change-Id: I0dbd5cb9d2c1119b2f263f60ed470bc8fef85d1e
diff --git a/main/src/main/java/org/onap/policy/api/main/service/ToscaServiceTemplateService.java b/main/src/main/java/org/onap/policy/api/main/service/ToscaServiceTemplateService.java
index d578d0d..2e8fc9e 100644
--- a/main/src/main/java/org/onap/policy/api/main/service/ToscaServiceTemplateService.java
+++ b/main/src/main/java/org/onap/policy/api/main/service/ToscaServiceTemplateService.java
@@ -550,14 +550,13 @@
throws PfModelException {
LOGGER.debug("->getNodeTemplate: name={}, version={}", name, version);
List<ToscaNodeTemplate> nodeTemplates = new ArrayList<>();
- var jpaNodeTemplates = new JpaToscaNodeTemplates();
var dbServiceTemplate = getDefaultJpaToscaServiceTemplate();
//Return empty if no nodeTemplates present in db
if (!ToscaUtils.doNodeTemplatesExist(dbServiceTemplate)) {
return nodeTemplates;
}
- jpaNodeTemplates = dbServiceTemplate.getTopologyTemplate().getNodeTemplates();
+ var jpaNodeTemplates = new JpaToscaNodeTemplates(dbServiceTemplate.getTopologyTemplate().getNodeTemplates());
//Filter specific nodeTemplates
if (name != null && version != null) {