mirror of https://github.com/apache/openjpa.git
fix Spec compat tests to work with all DBs
test should rely on whether KEY is a reserved word or not.
This commit is contained in:
parent
d8bb07fe86
commit
90ba3b8d5d
|
@ -419,7 +419,13 @@ public class TestContainerSpecCompatibilityOptions
|
||||||
// trigger table creation
|
// trigger table creation
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", "KEY0");
|
|
||||||
|
// on some databases KEY is a forbidden name for columns.
|
||||||
|
String keyColumn = getDbDictioary(emf).getInvalidColumnWordSet().contains("KEY")
|
||||||
|
? "KEY0"
|
||||||
|
: "KEY";
|
||||||
|
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", keyColumn);
|
||||||
|
|
||||||
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
|
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
|
||||||
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
|
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
|
||||||
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
|
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
|
||||||
|
|
|
@ -410,7 +410,13 @@ extends AbstractCachedEMFTestCase {
|
||||||
// trigger table creation
|
// trigger table creation
|
||||||
em.getTransaction().begin();
|
em.getTransaction().begin();
|
||||||
em.getTransaction().commit();
|
em.getTransaction().commit();
|
||||||
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", "KEY0");
|
|
||||||
|
// on some databases KEY is a forbidden name for columns.
|
||||||
|
String keyColumn = getDbDictioary(emf).getInvalidColumnWordSet().contains("KEY")
|
||||||
|
? "KEY0"
|
||||||
|
: "KEY";
|
||||||
|
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_FK", "Uni1MFK_ID", keyColumn);
|
||||||
|
|
||||||
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
|
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_JT_C", "B_ID", "C_ID");
|
||||||
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
|
assertSQLFragnments(sql, "CREATE TABLE C_U1M_Map_RelKey_FK", "Uni1MFK_ID");
|
||||||
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
|
assertSQLFragnments(sql, "CREATE TABLE Bi1M_Map_RelKey_JT_C", "B_ID", "C_ID");
|
||||||
|
@ -867,8 +873,7 @@ extends AbstractCachedEMFTestCase {
|
||||||
map.put("openjpa.MetaDataFactory", "jpa(Types=" + buf.toString() + oldValue + ")");
|
map.put("openjpa.MetaDataFactory", "jpa(Types=" + buf.toString() + oldValue + ")");
|
||||||
return (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
|
return (OpenJPAEntityManagerFactorySPI)OpenJPAPersistence.
|
||||||
createEntityManagerFactory("persistence_2_0",
|
createEntityManagerFactory("persistence_2_0",
|
||||||
"org/apache/openjpa/persistence/compat/" +
|
"org/apache/openjpa/persistence/compat/persistence_2_0.xml", map);
|
||||||
"persistence_2_0.xml", map);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void assertSQLFragnments(List<String> list, String... keys) {
|
void assertSQLFragnments(List<String> list, String... keys) {
|
||||||
|
|
|
@ -38,10 +38,13 @@ import javax.persistence.EntityManager;
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
import javax.persistence.Persistence;
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
|
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||||
|
import org.apache.openjpa.jdbc.sql.DBDictionary;
|
||||||
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
import org.apache.openjpa.kernel.AbstractBrokerFactory;
|
||||||
import org.apache.openjpa.kernel.Broker;
|
import org.apache.openjpa.kernel.Broker;
|
||||||
import org.apache.openjpa.meta.ClassMetaData;
|
import org.apache.openjpa.meta.ClassMetaData;
|
||||||
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
import org.apache.openjpa.persistence.JPAFacadeHelper;
|
||||||
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
|
||||||
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
import org.apache.openjpa.persistence.OpenJPAPersistence;
|
||||||
|
|
||||||
|
@ -355,6 +358,11 @@ public abstract class AbstractPersistenceTestCase extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected DBDictionary getDbDictioary(EntityManagerFactory emf) {
|
||||||
|
return ((JDBCConfiguration)((OpenJPAEntityManagerFactory) emf).getConfiguration()).getDBDictionaryInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the entity name for the given type.
|
* Return the entity name for the given type.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue