openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject [openjpa] branch master updated: ensure TestSnakeCaseDDL runs in enhanced mode otherwise there is an issue in column name uniqueness check + fixing MappingDefaultsImpl name definition
Date Thu, 07 May 2020 08:41:38 GMT
This is an automated email from the ASF dual-hosted git repository.

rmannibucau pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openjpa.git


The following commit(s) were added to refs/heads/master by this push:
     new e721abf  ensure TestSnakeCaseDDL runs in enhanced mode otherwise there is an issue
in column name uniqueness check + fixing MappingDefaultsImpl name definition
e721abf is described below

commit e721abfdaa5a89489f7fec11d4cf3a0d2b804556
Author: Romain Manni-Bucau <rmannibucau@gmail.com>
AuthorDate: Thu May 7 10:02:45 2020 +0200

    ensure TestSnakeCaseDDL runs in enhanced mode otherwise there is an issue in column name
uniqueness check + fixing MappingDefaultsImpl name definition
---
 .../java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java |  2 +-
 .../org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java  | 10 ++++------
 .../java/org/apache/openjpa/jdbc/sql/TestSnakeCaseDDL.java     |  5 +++--
 3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
index c9f872e..0554235 100644
--- a/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
+++ b/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingDefaultsImpl.java
@@ -643,7 +643,7 @@ public class MappingDefaultsImpl
             corrected = true;
         }
         if (corrected) {
-            name = dict.getValidColumnName(name, table, false);
+            name = dict.getValidColumnName(name, table, true);
             col.setIdentifier(name);
             table.addCorrectedColumnName(name, true);
         }
diff --git a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
index f779a04..99dbf71 100644
--- a/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
+++ b/openjpa-jdbc/src/test/java/org/apache/openjpa/jdbc/meta/TestMappingDefaultsImpl.java
@@ -26,6 +26,7 @@ import org.apache.openjpa.jdbc.schema.Table;
 import org.junit.Test;
 
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
 
 public class TestMappingDefaultsImpl {
 
@@ -52,11 +53,8 @@ public class TestMappingDefaultsImpl {
         mr.setConfiguration(conf);
         Version version = new Version(new ClassMapping(String.class,mr));
         mapping.populateColumns(version, table, cols);
-        assertFalse("column names are conflicted : " + cols[0].getName(),
-                cols[0].getName().equals(cols[1].getName()));
-        assertFalse("column names are conflicted : " + cols[0].getName(),
-                cols[0].getName().equals(cols[2].getName()));
-        assertFalse("column names are conflicted : " + cols[1].getName(),
-                cols[1].getName().equals(cols[2].getName()));
+        assertNotEquals("column names are conflicted : " + cols[0].getName(), cols[0].getName(),
cols[1].getName());
+        assertNotEquals("column names are conflicted : " + cols[0].getName(), cols[0].getName(),
cols[2].getName());
+        assertNotEquals("column names are conflicted : " + cols[1].getName(), cols[1].getName(),
cols[2].getName());
     }
 }
diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestSnakeCaseDDL.java
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestSnakeCaseDDL.java
index 053ccfa..94d1a51 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestSnakeCaseDDL.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/jdbc/sql/TestSnakeCaseDDL.java
@@ -57,7 +57,6 @@ public class TestSnakeCaseDDL {
         ds.setUrl("jdbc:derby:memory:ddlInSnakeCase;create=true");
         persistenceUnitInfo.setJtaDataSource(ds);
         persistenceUnitInfo.setProperty("openjpa.jdbc.DBDictionary", "derby(javaToDbColumnNameProcessing=snake_case)");
-        persistenceUnitInfo.setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
         new PersistenceProviderImpl().generateSchema(persistenceUnitInfo, new HashMap<>());
         final Collection<String> createdTables = new HashSet<>();
         final Map<String, Collection<String>> columns = new HashMap<>();
@@ -95,7 +94,9 @@ public class TestSnakeCaseDDL {
                     em.persist(entity);
                     em.getTransaction().commit();
                 } catch (final RuntimeException re) {
-                    em.getTransaction().rollback();
+                    if (em.getTransaction().isActive()) {
+                        em.getTransaction().rollback();
+                    }
                     throw re;
                 } finally {
                     em.close();


Mime
View raw message