Change template query to return a result when duplicate rows exists 76/129776/3
authorkuldipr <kuldip.rai@amdocs.com>
Fri, 17 Jun 2022 16:18:35 +0000 (12:18 -0400)
committerJozsef Csongvai <jozsef.csongvai@bell.ca>
Tue, 12 Jul 2022 12:35:22 +0000 (12:35 +0000)
Issue-ID: CCSDK-3714
Change-Id: I516efc75d5d789903883437b6f3b50874bcfc79a
Signed-off-by: kuldipr <kuldip.rai@amdocs.com>
ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/db/TemplateResolutionRepository.kt

index 38d61e7..0d8946e 100644 (file)
@@ -24,6 +24,16 @@ import javax.transaction.Transactional
 @Repository
 interface TemplateResolutionRepository : JpaRepository<TemplateResolution, String> {
 
+    @Query(
+        value = """
+        SELECT * FROM TEMPLATE_RESOLUTION
+             WHERE resource_type = :resourceType AND resource_id = :resourceId
+             AND blueprint_name = :blueprintName AND blueprint_version = :blueprintVersion
+             AND artifact_name = :artifactName AND occurrence = :occurrence
+             ORDER BY creation_date DESC LIMIT 1
+        """,
+        nativeQuery = true
+    )
     fun findByResourceIdAndResourceTypeAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
         resourceId: String,
         resourceType: String,
@@ -33,6 +43,15 @@ interface TemplateResolutionRepository : JpaRepository<TemplateResolution, Strin
         occurrence: Int
     ): TemplateResolution?
 
+    @Query(
+        value = """
+        SELECT * FROM TEMPLATE_RESOLUTION WHERE resolution_key = :key 
+             AND blueprint_name = :blueprintName AND blueprint_version = :blueprintVersion 
+             AND artifact_name = :artifactName AND occurrence = :occurrence
+             ORDER BY creation_date DESC LIMIT 1
+        """,
+        nativeQuery = true
+    )
     fun findByResolutionKeyAndBlueprintNameAndBlueprintVersionAndArtifactNameAndOccurrence(
         key: String,
         blueprintName: String?,