OPENJPA-2753 postgres doesn't know BLOG

have to use BYTEA instead.
This commit is contained in:
Mark Struberg 2018-11-10 16:45:24 +01:00
parent 7bc09297f8
commit 60ccac0e22
2 changed files with 36 additions and 2 deletions

View File

@ -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);

View File

@ -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));