empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1345893 - in /empire-db/trunk/empire-db: pom.xml src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java src/test/java/org/apache/empire/DBResource.java src/test/java/org/apache/empire/db/CompanyDB.java
Date Mon, 04 Jun 2012 09:43:30 GMT
Author: francisdb
Date: Mon Jun  4 09:43:30 2012
New Revision: 1345893

URL: http://svn.apache.org/viewvc?rev=1345893&view=rev
Log:
EMPIREDB-146 blob data type is not working with postgresql under v2.3

Modified:
    empire-db/trunk/empire-db/pom.xml
    empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
    empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java
    empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java

Modified: empire-db/trunk/empire-db/pom.xml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/pom.xml?rev=1345893&r1=1345892&r2=1345893&view=diff
==============================================================================
--- empire-db/trunk/empire-db/pom.xml (original)
+++ empire-db/trunk/empire-db/pom.xml Mon Jun  4 09:43:30 2012
@@ -74,7 +74,13 @@
 		    <artifactId>jtds</artifactId>
 		    <version>1.2.4</version>
 		    <scope>test</scope>
-		</dependency> -->
+		</dependency>
+		<dependency>
+		    <groupId>postgresql</groupId>
+		    <artifactId>postgresql</artifactId>
+		    <version>9.1-901.jdbc4</version>
+		    <scope>test</scope>
+		</dependency>  -->
 		<dependency>
 		    <groupId>commons-io</groupId>
 		    <artifactId>commons-io</artifactId>

Modified: empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java?rev=1345893&r1=1345892&r2=1345893&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
(original)
+++ empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/PostgreDDLGenerator.java
Mon Jun  4 09:43:30 2012
@@ -46,6 +46,7 @@ public class PostgreDDLGenerator extends
     {   // Override data types
         DATATYPE_BOOLEAN = "BOOLEAN";
         DATATYPE_CLOB = "TEXT";
+        DATATYPE_BLOB = "BYTEA";
     }
 
     @Override

Modified: empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java?rev=1345893&r1=1345892&r2=1345893&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java (original)
+++ empire-db/trunk/empire-db/src/test/java/org/apache/empire/DBResource.java Mon Jun  4 09:43:30
2012
@@ -28,6 +28,7 @@ import org.apache.empire.db.DBTools;
 import org.apache.empire.db.derby.DBDatabaseDriverDerby;
 import org.apache.empire.db.h2.DBDatabaseDriverH2;
 import org.apache.empire.db.hsql.DBDatabaseDriverHSql;
+import org.apache.empire.db.postgresql.DBDatabaseDriverPostgreSQL;
 import org.apache.empire.db.sqlserver.DBDatabaseDriverMSSQL;
 import org.junit.rules.ExternalResource;
 
@@ -67,7 +68,9 @@ public class DBResource extends External
         throws Throwable
     {   
         Class.forName(db.jdbcClass);
-        connection = DriverManager.getConnection(db.jdbcURL, "sa", "");
+        String user = db.username != null ? db.username:"sa";
+        String password = db.password != null ? db.password:"";
+        connection = DriverManager.getConnection(db.jdbcURL, user, password);
     }
     
     @Override
@@ -106,6 +109,12 @@ public class DBResource extends External
               "org.h2.Driver", 
               "jdbc:h2:mem:data/h2/test",
               DBDatabaseDriverH2.class),
+        POSTGRESQL(
+              "org.postgresql.Driver", 
+              "jdbc:postgresql://localhost",
+              DBDatabaseDriverPostgreSQL.class,
+              "postgres",
+              "postgres"),
         MSSQL(
               "com.microsoft.sqlserver.jdbc.SQLServerDriver", 
               "jdbc:sqlserver://localhost:1433",
@@ -118,13 +127,22 @@ public class DBResource extends External
 
         private final String jdbcClass;
         private final String jdbcURL;
+        private final String username;
+        private final String password;
         private final Class<? extends DBDatabaseDriver> driver;
         
         private DB(final String jdbcClass, final String jdbcURL, final Class<? extends
DBDatabaseDriver> driver)
         {
+        	this(jdbcClass, jdbcURL, driver, null, null);
+        }
+        
+        private DB(final String jdbcClass, final String jdbcURL, final Class<? extends
DBDatabaseDriver> driver, final String username, final String password)
+        {
             this.driver = driver;
             this.jdbcClass = jdbcClass;
             this.jdbcURL = jdbcURL;
+            this.username = username;
+            this.password = password;
         }
     }
 }

Modified: empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java?rev=1345893&r1=1345892&r2=1345893&view=diff
==============================================================================
--- empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java (original)
+++ empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java Mon Jun  4
09:43:30 2012
@@ -112,10 +112,36 @@ public class CompanyDB extends DBDatabas
             GENDER.setOptions(genders);
         }
     }
+    
+    /**
+     * This class represents the definition of the Departments table.
+     */
+    public static class Data extends DBTable
+    {
+        private final static long serialVersionUID = 1L;
+        public final DBTableColumn ID;
+        public final DBTableColumn DATA;
+        public final DBTableColumn UPDATE_TIMESTAMP;
+
+        public Data(DBDatabase db)
+        {
+            super("DATA", db);
+            // ID
+            ID              = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, DataMode.AutoGenerated,
"DATA_ID_SEQUENCE");
+            DATA            = addColumn("NAME",             DataType.BLOB,          0, DataMode.NotNull);
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, DataMode.NotNull);
+
+            // Primary Key
+            setPrimaryKey(ID);
+            // Set timestamp column for save updates
+            setTimestampColumn(UPDATE_TIMESTAMP);
+        }
+    }
 
     // Declare all Tables and Views here
     public final Departments  DEPARTMENT = new Departments(this);
     public final Employees    EMPLOYEE   = new Employees(this);
+    public final Data         DATA       = new Data(this);
 
     /**
      * Constructor of the CompanyDB data model description



Mime
View raw message