mirror of
https://github.com/apache/openjpa.git
synced 2025-02-22 18:32:06 +00:00
ensure TestSnakeCaseDDL runs in enhanced mode otherwise there is an issue in column name uniqueness check + fixing MappingDefaultsImpl name definition
This commit is contained in:
parent
868a446a3e
commit
e721abfdaa
@ -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);
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user