openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject [openjpa] 01/02: OPENJPA-2753 postgres doesn't know BLOG
Date Sat, 10 Nov 2018 19:49:17 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 60ccac0e2201b023fa6194523ab733ea12ee1172
Author: Mark Struberg <struberg@apache.org>
AuthorDate: Sat Nov 10 16:45:24 2018 +0100

    OPENJPA-2753 postgres doesn't know BLOG
    
    have to use BYTEA instead.
---
 .../schema/TestSchemaGenerationProperties.java     | 24 ++++++++++++++++++++--
 .../persistence/jdbc/schema/create-postgresql.sql  | 14 +++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
index c2e75fe..b74c4a6 100644
--- a/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
+++ b/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/jdbc/schema/TestSchemaGenerationProperties.java
@@ -30,6 +30,8 @@ import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
 import org.apache.openjpa.jdbc.meta.MappingTool;
 import org.apache.openjpa.jdbc.schema.SchemaGroup;
 import org.apache.openjpa.jdbc.schema.SchemaTool;
+import org.apache.openjpa.jdbc.sql.DBDictionary;
+import org.apache.openjpa.jdbc.sql.PostgresDictionary;
 import org.apache.openjpa.persistence.OpenJPAEntityManager;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
 import org.apache.openjpa.persistence.OpenJPAEntityManagerFactorySPI;
@@ -139,13 +141,23 @@ public class TestSchemaGenerationProperties extends BaseJDBCTest {
     }
 
     public void testSchemaGenScriptCreate() throws Exception {
+
         testSchemaGenMetadataDrop();
 
+        JDBCConfiguration conf = (JDBCConfiguration) getPM().getConfiguration();
+        DBDictionary dict = conf.getDBDictionaryInstance();
+
+        String createSql =
+                dict instanceof PostgresDictionary
+                        ? "org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql"
+                        : "org/apache/openjpa/persistence/jdbc/schema/create.sql";
+
+
         Map<String, String> properties = new HashMap<>();
         properties.put("javax.persistence.schema-generation.database.action", "create");
         properties.put("javax.persistence.schema-generation.create-source", "script");
         properties.put("javax.persistence.schema-generation.create-script-source",
-                       "org/apache/openjpa/persistence/jdbc/schema/create.sql");
+                       createSql);
 
         SchemaGroup dbSchemaGroup = getSchemaGroup(properties);
 
@@ -158,6 +170,14 @@ public class TestSchemaGenerationProperties extends BaseJDBCTest {
     public void testSchemaGenScriptDropAndCreate() throws Exception {
         testSchemaGenMetadataCreate();
 
+        JDBCConfiguration conf = (JDBCConfiguration) getPM().getConfiguration();
+        DBDictionary dict = conf.getDBDictionaryInstance();
+
+        String createSql =
+                dict instanceof PostgresDictionary
+                        ? "org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql"
+                        : "org/apache/openjpa/persistence/jdbc/schema/create.sql";
+
         Map<String, String> properties = new HashMap<>();
         properties.put("javax.persistence.schema-generation.database.action", "drop-and-create");
         properties.put("javax.persistence.schema-generation.drop-source", "script");
@@ -165,7 +185,7 @@ public class TestSchemaGenerationProperties extends BaseJDBCTest {
                        "org/apache/openjpa/persistence/jdbc/schema/drop.sql");
         properties.put("javax.persistence.schema-generation.create-source", "script");
         properties.put("javax.persistence.schema-generation.create-script-source",
-                       "org/apache/openjpa/persistence/jdbc/schema/create.sql");
+                       createSql);
 
         SchemaGroup dbSchemaGroup = getSchemaGroup(properties);
 
diff --git a/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql
b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql
new file mode 100644
index 0000000..4a7f07a
--- /dev/null
+++ b/openjpa-persistence-jdbc/src/test/resources/org/apache/openjpa/persistence/jdbc/schema/create-postgresql.sql
@@ -0,0 +1,14 @@
+CREATE TABLE AUTOINCPC1 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), DTYPE VARCHAR(255), ONEONE_ID
INTEGER, INTFIELD INTEGER, CONSTRAINT SQL150111133630290 PRIMARY KEY (ID));
+CREATE TABLE AUTOINCPC3 (ID BIGINT NOT NULL, STRNGFLD VARCHAR(50), ONEONE_ID BIGINT, CONSTRAINT
SQL150111133630380 PRIMARY KEY (ID));
+CREATE TABLE CONJOINPC4 (ID INTEGER NOT NULL, MANYTOMANY BYTEA, NAME VARCHAR(50), ONETOONE1_ID
INTEGER, CONSTRAINT SQL150111133630400 PRIMARY KEY (ID));
+CREATE TABLE CONJOINPC5 (ID INTEGER NOT NULL, NAME VARCHAR(255), CONSTRAINT SQL150111133630420
PRIMARY KEY (ID));
+CREATE TABLE CUSTMAPPC (ID INTEGER NOT NULL, FEMALE SMALLINT, NAME VARCHAR(50), CONSTRAINT
SQL150111133630430 PRIMARY KEY (ID));
+CREATE TABLE DFGTEST (ID BIGINT NOT NULL, DFGFIELD INTEGER, NONDFGFIELD INTEGER, CONSTRAINT
SQL150111133630450 PRIMARY KEY (ID));
+CREATE TABLE EAGEROUTERJOINPC (ID BIGINT NOT NULL, NAME VARCHAR(255), HELPER BYTEA, CONSTRAINT
SQL150111133630460 PRIMARY KEY (ID));
+CREATE TABLE EAGERPC (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), EAGER_ID INTEGER, EAGSUB
INTEGER, HELPER_ID INTEGER, RECURSE_ID INTEGER, CONSTRAINT SQL150111133630470 PRIMARY KEY
(ID));
+CREATE TABLE EAGERPCSUB (ID INTEGER NOT NULL, INTFIELD INTEGER, CONSTRAINT SQL150111133630480
PRIMARY KEY (ID));
+CREATE TABLE HELPERPC (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), EAGER_ID INTEGER, HELPER
BYTEA, CONSTRAINT SQL150111133630500 PRIMARY KEY (ID));
+CREATE TABLE HELPERPC2 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), HELPER_ID INTEGER, CONSTRAINT
SQL150111133630510 PRIMARY KEY (ID));
+CREATE TABLE HELPERPC3 (ID INTEGER NOT NULL, STRNGFLD VARCHAR(50), DTYPE VARCHAR(255), INTFIELD
INTEGER, CONSTRAINT SQL150111133630520 PRIMARY KEY (ID));
+CREATE TABLE INVERTA (ID INTEGER NOT NULL, TEST VARCHAR(35), INVERTB_ID INTEGER, CONSTRAINT
SQL150111133630530 PRIMARY KEY (ID));
+CREATE TABLE INVERTB (ID INTEGER NOT NULL, TEST VARCHAR(35), INVERTA_ID INTEGER, CONSTRAINT
SQL150111133630540 PRIMARY KEY (ID));


Mime
View raw message