From 816c7e595838356aeb80b9730ae72edb6519f05e Mon Sep 17 00:00:00 2001
From: Jason Froehlich <jfroehlich12@gmail.com>
Date: Wed, 15 Jan 2025 13:00:09 -0500
Subject: [PATCH] #166 Added changes to make rules more robust

Signed-off-by: Jason Froehlich <jfroehlich12@gmail.com>
---
 ...spring-framework-5.x-to-6.0-data-access.yaml | 17 +++++++++--------
 .../tests/data/data-access/pom.xml              |  6 ++++++
 .../src/main/resources/META-INF/persistence.xml | 10 ----------
 ...g-framework-5.x-to-6.0-data-access.test.yaml |  4 ++--
 4 files changed, 17 insertions(+), 20 deletions(-)
 delete mode 100644 default/generated/spring-framework/tests/data/data-access/src/main/resources/META-INF/persistence.xml

diff --git a/default/generated/spring-framework/spring-framework-5.x-to-6.0-data-access.yaml b/default/generated/spring-framework/spring-framework-5.x-to-6.0-data-access.yaml
index 26e5ecb3..c7f8a783 100644
--- a/default/generated/spring-framework/spring-framework-5.x-to-6.0-data-access.yaml
+++ b/default/generated/spring-framework/spring-framework-5.x-to-6.0-data-access.yaml
@@ -39,16 +39,12 @@
   when:
     or:
     - builtin.filecontent:
-        filePattern: (hibernate\.properties|persistence\.xml|cfg\.xml|application\.properties|application\.yaml)
+        filePattern: .*\.properties
         pattern: hibernate.bytecode.provider=javassist
     - builtin.xml:
         namespaces:
           s: http://www.hibernate.org/xsd/hibernate-configuration
         xpath: "/hibernate-configuration/session-factory/property[@name='hibernate.bytecode.provider' and text()='javassist']" 
-    - builtin.xml:
-        namespaces:
-          s: http://java.sun.com/xml/ns/persistence
-        xpath: /persistence/persistence-unit/properties/property[@name='hibernate.bytecode.provider' and @value='javassist']
     - java.referenced:
         pattern: org.hibernate.bytecode.javassist*
     - builtin.filecontent:
@@ -84,16 +80,21 @@
             filePattern: .*\.(java|properties|xml)
             pattern: org.hibernate.dialect.PostgreSQL81Dialect
         - java.dependency:
-            name: postgresql
+            lowerbound: 0.0.0
+            name: org.postgresql.postgresql
   description: Changes to the DDL type for CLOB
   message: |
     Using `@Lob` or `java.sql.Clob` with PostgreSQL 8.1 dialect might require DDL type changes for CLOBs.
 
     Consider reviewing DDL generation for CLOB columns and potential migration to 'oid' type if necessary.
 
-    All PostgreSQL JDBC drivers unfortunately just store the oid it created for a `java.sql.Clob` into the text column. Although reading back the value with the CLOB API works, PostgreSQL has no knowledge of the reference to the LOB, because the oid is not known to PostgreSQL, leading to data loss when vacuumlo (the utility to clean up unused LOBs) runs. To avoid the data loss, it is required to use the oid type so that vacuumlo can see the reference.
+    All PostgreSQL JDBC drivers unfortunately just store the oid it created for a `java.sql.Clob` into the text column. 
+    Although reading back the value with the CLOB API works, PostgreSQL has no knowledge of the reference to the LOB, 
+    because the oid is not known to PostgreSQL, leading to data loss when vacuumlo (the utility to clean up unused LOBs) runs. 
+    To avoid the data loss, it is required to use the oid type so that vacuumlo can see the reference.
 
-    Updating to 5.6.2 does not require any schema or application changes by default, but we highly recommend that you migrate existing text columns for LOBs to oid to prevent data loss due to the activity of vacuumlo. 
+    Updating to 5.6.2 does not require any schema or application changes by default, but we highly recommend that you migrate 
+    existing text columns for LOBs to oid to prevent data loss due to the activity of vacuumlo. 
   links:
   - title: 'Hibernate 5.6 migration guide - Changes to the DDL type for CLOB'
     url: https://github.com/hibernate/hibernate-orm/blob/5.6/migration-guide.adoc#changes-to-the-ddl-type-for-clob-in-postgresql81dialect-and-its-subclasses
diff --git a/default/generated/spring-framework/tests/data/data-access/pom.xml b/default/generated/spring-framework/tests/data/data-access/pom.xml
index 92531b1a..3bc66426 100644
--- a/default/generated/spring-framework/tests/data/data-access/pom.xml
+++ b/default/generated/spring-framework/tests/data/data-access/pom.xml
@@ -70,6 +70,12 @@
             <version>8.0.30</version>
         </dependency>
 
+        <dependency>
+            <groupId>org.postgresql</groupId>
+            <artifactId>postgresql</artifactId>
+            <version>42.5.4</version> 
+        </dependency>
+
         <!-- Logging -->
         <dependency>
             <groupId>org.slf4j</groupId>
diff --git a/default/generated/spring-framework/tests/data/data-access/src/main/resources/META-INF/persistence.xml b/default/generated/spring-framework/tests/data/data-access/src/main/resources/META-INF/persistence.xml
deleted file mode 100644
index df8e4232..00000000
--- a/default/generated/spring-framework/tests/data/data-access/src/main/resources/META-INF/persistence.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<persistence version="2.2"
-    xmlns="http://xmlns.jcp.org/xml/ns/persistence"
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_2.xsd">
-    <persistence-unit name="myPersistenceUnit">
-        <properties>
-            <property name="hibernate.bytecode.provider" value="javassist" />
-        </properties>
-    </persistence-unit>
-</persistence>
\ No newline at end of file
diff --git a/default/generated/spring-framework/tests/spring-framework-5.x-to-6.0-data-access.test.yaml b/default/generated/spring-framework/tests/spring-framework-5.x-to-6.0-data-access.test.yaml
index 7fe8a0ef..e30fd9db 100644
--- a/default/generated/spring-framework/tests/spring-framework-5.x-to-6.0-data-access.test.yaml
+++ b/default/generated/spring-framework/tests/spring-framework-5.x-to-6.0-data-access.test.yaml
@@ -16,14 +16,14 @@ tests:
     analysisParams:
       mode: "source-only"
     hasIncidents:
-      exactly: 5
+      exactly: 4
 - ruleID: spring-framework-5.x-to-6.0-data-access-00003
   testCases:
   - name: tc-1
     analysisParams:
       mode: "source-only"
     hasIncidents:
-      exactly: 4
+      exactly: 5
 - ruleID: spring-framework-5.x-to-6.0-data-access-00010
   testCases:
     - name: tc-1