empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r903490 [1/2] - in /incubator/empire-db/trunk: empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/ empire-db-examples/empire-db-example-basic/ empire-db-examples/empire-db-example-basic/src/mai...
Date Tue, 26 Jan 2010 23:34:17 GMT
Author: doebele
Date: Tue Jan 26 23:34:14 2010
New Revision: 903490

URL: http://svn.apache.org/viewvc?rev=903490&view=rev
Log:
EMPIREDB-71

Added:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java   (with props)
Modified:
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/SampleAction.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/db/SampleDB.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
    incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/Action.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/Column.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataType.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanDomain.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBView.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/CompanyDB.java
    incubator/empire-db/trunk/empire-db/src/test/java/org/apache/empire/db/DBCommandTest.java

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvApp.java Tue Jan 26 23:34:14 2010
@@ -28,6 +28,7 @@
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 import org.apache.empire.db.DBCmdType;
 import org.apache.empire.db.DBColumnExpr;
 import org.apache.empire.db.DBCommand;
@@ -416,7 +417,7 @@
         DBCommand cmd = db.createCommand();
         // Define shortcuts for tables used - not necessary but convenient
         SampleAdvDB.Employees EMP = T_EMP;
-        // Select requried columns
+        // Select required columns
         cmd.select(T_EMP.getColumns());
         // Set Constraints
         cmd.where(T_EMP.C_RETIRED.is(false));
@@ -470,7 +471,7 @@
     {
         // Define the query
         DBCommand cmd = db.createCommand();
-        // Select requried columns
+        // Select required columns
         cmd.select(T_EMP.getColumns());
         // Set Constraints
         cmd.where(T_EMP.C_RETIRED.is(false));
@@ -511,7 +512,7 @@
         db.getDriver().setDDLColumnDefaults(true);
 
         // First, add a new column to the Table object
-        DBTableColumn C_FOO = db.T_EMPLOYEES.addColumn("FOO", DataType.TEXT, 20, false);
+        DBTableColumn C_FOO = db.T_EMPLOYEES.addColumn("FOO", DataType.TEXT, 20, DataMode.Nullable);
 
         // Now create the corresponding DDL statement 
         System.out.println("Creating new column named FOO as varchar(20) for the EMPLOYEES table:");
@@ -546,7 +547,7 @@
     }
 
     /**
-     * This function demostrates the use of the DBQuery object.<BR>
+     * This function demonstrates the use of the DBQuery object.<BR>
      * First a DBQuery is used to define a subquery that gets the latest employee department history record.<BR>
      * This subquery is then used inside another query to list all employees with the current department.<BR>
      * <P>
@@ -568,7 +569,7 @@
 
         // Define the query
         DBCommand cmd = db.createCommand();
-        // Select requried columns
+        // Select required columns
         cmd.select(T_EMP.C_EMPLOYEE_ID, T_EMP.C_FULLNAME);
         cmd.select(T_EMP.C_GENDER, T_EMP.C_PHONE_NUMBER);
         cmd.select(T_DEP.C_DEPARTMENT_ID, T_DEP.C_NAME, T_DEP.C_BUSINESS_UNIT);
@@ -595,7 +596,7 @@
         rec.setValue(T_EMP.C_PHONE_NUMBER, "0815-4711");
         rec.setValue(T_DEP.C_BUSINESS_UNIT, "AUTO");
         rec.update(conn);
-        // Sucessfully updated
+        // Successfully updated
         System.out.println("The employee has been sucessfully updated");
     }    
 

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-advanced/src/main/java/org/apache/empire/samples/db/advanced/SampleAdvDB.java Tue Jan 26 23:34:14 2010
@@ -20,6 +20,7 @@
 
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBColumnExpr;
 import org.apache.empire.db.DBCommand;
@@ -37,8 +38,8 @@
  *
  * PLEASE NOTE THE NAMING CONVENTION:
  * Since all tables, views and columns are declared as "final" constants they are all in upper case.
- * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them togehter
- * when listed in your IDE's code completition.
+ * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them together
+ * when listed in your IDE's code completion.
  * There is no need to stick to this convention but it makes life just another little bit easier.
  *
  * You may declare other database tables or views in the same way.
@@ -61,11 +62,11 @@
         {
             super("DEPARTMENTS", db);
             // ID
-            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, true, "DEP_ID_SEQUENCE");
-            C_NAME            = addColumn("NAME",             DataType.TEXT,         80, true);
-            C_HEAD            = addColumn("HEAD",             DataType.TEXT,         80, false);
-            C_BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, true, "ITTK");
-            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, true);
+            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, DataMode.AutoGenerated, "DEP_ID_SEQUENCE");
+            C_NAME            = addColumn("NAME",             DataType.TEXT,         80, DataMode.NotNull);
+            C_HEAD            = addColumn("HEAD",             DataType.TEXT,         80, DataMode.Nullable);
+            C_BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, DataMode.NotNull, "ITTK");
+            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, DataMode.AutoGenerated);
 
             // Primary Key
             setPrimaryKey(C_DEPARTMENT_ID);
@@ -100,17 +101,17 @@
         {
             super("EMPLOYEES", db);
             // ID
-            C_EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, true, "EMPLOYEE_ID_SEQUENCE");
-            C_SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, false);
-            C_FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, true);
-            C_LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, true);
-            C_DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, false);
-            C_GENDER          = addColumn("GENDER",           DataType.TEXT,         1, false);
-            C_PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, false);
-            C_EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, false);
-            C_RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, true, false);
-            C_CHECKSUM        = addColumn("CHECKSUM",         DataType.INTEGER,      0, false);
-            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, true);
+            C_EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, DataMode.AutoGenerated, "EMPLOYEE_ID_SEQUENCE");
+            C_SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, DataMode.Nullable);
+            C_FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, DataMode.NotNull);
+            C_LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, DataMode.NotNull);
+            C_DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, DataMode.Nullable);
+            C_GENDER          = addColumn("GENDER",           DataType.TEXT,         1, DataMode.Nullable);
+            C_PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, DataMode.Nullable);
+            C_EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, DataMode.Nullable);
+            C_RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, DataMode.NotNull, false);
+            C_CHECKSUM        = addColumn("CHECKSUM",         DataType.INTEGER,      0, DataMode.Nullable);
+            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, DataMode.AutoGenerated);
 
             // Primary Key
             setPrimaryKey(C_EMPLOYEE_ID);
@@ -144,9 +145,9 @@
         {
             super("EMPLOYEE_DEPARTMENT_HIST", db);
             // ID
-            C_EMPLOYEE_ID   = addColumn("EMPLOYEE_ID",      DataType.INTEGER,       0, true);
-            C_DEPARTMENT_ID = addColumn("DEPARTMENT_ID",    DataType.INTEGER,       0, true);
-            C_DATE_FROM     = addColumn("DATE_FROM",        DataType.DATE,          0, true);
+            C_EMPLOYEE_ID   = addColumn("EMPLOYEE_ID",      DataType.INTEGER,       0, DataMode.NotNull);
+            C_DEPARTMENT_ID = addColumn("DEPARTMENT_ID",    DataType.INTEGER,       0, DataMode.NotNull);
+            C_DATE_FROM     = addColumn("DATE_FROM",        DataType.DATE,          0, DataMode.NotNull);
 
             // Primary Key
             setPrimaryKey(C_EMPLOYEE_ID, C_DATE_FROM);
@@ -234,7 +235,7 @@
 
             // Define the query
             DBCommand cmd = db.createCommand();
-            // Select requried columns
+            // Select required columns
             cmd.select(T_EMP.C_EMPLOYEE_ID);
             cmd.select(T_DEP.C_DEPARTMENT_ID);
             cmd.select(T_EMP.C_LASTNAME.append(", ")
@@ -261,7 +262,7 @@
     /**
      * Constructor of the SampleDB data model description
      *
-     * Put all foreigen key realtions here.
+     * Put all foreign key relations here.
      */
     public SampleAdvDB()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/config.xml Tue Jan 26 23:34:14 2010
@@ -88,9 +88,9 @@
 		<!-- JDBC properties for a Microsoft SQL-Server Database connection -->
 		<!-- Required jar file: sqljdbc.jar -->
 		<jdbcClass>com.microsoft.sqlserver.jdbc.SQLServerDriver</jdbcClass>
-		<jdbcURL>jdbc:sqlserver://localhost:1433</jdbcURL>
-		<jdbcUser>empire-db</jdbcUser>
-		<jdbcPwd>empire-db</jdbcPwd>
+		<jdbcURL>jdbc:sqlserver://esteams2:1433</jdbcURL>
+		<jdbcUser>sa</jdbcUser>
+		<jdbcPwd>esteam</jdbcPwd>
 		<schemaName>DBSAMPLE</schemaName>
 	</properties-sqlserver>
 	

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleApp.java Tue Jan 26 23:34:14 2010
@@ -420,6 +420,11 @@
         cmd.orderBy(EMP.LASTNAME);
         cmd.orderBy(EMP.FIRSTNAME);
 
+        cmd.where(EMP.DEPARTMENT_ID.is("Some Strange Value"));
+        cmd.where(EMP.SALARY.is("Some Weird Value"));
+        cmd.where(EMP.EMPLOYEE_ID.is("Some Strange Value"));
+        System.out.print(cmd.getSelect());
+        
 		// Query Records and print output
 		DBReader reader = new DBReader();
 		try

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-basic/src/main/java/org/apache/empire/samples/db/SampleDB.java Tue Jan 26 23:34:14 2010
@@ -20,6 +20,7 @@
 
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTable;
@@ -33,8 +34,8 @@
  *
  * PLEASE NOTE THE NAMING CONVENTION:
  * Since all tables, views and columns are declared as "final" constants they are all in upper case.
- * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them togehter
- * when listed in your IDE's code completition.
+ * We recommend using a prefix of T_ for tables and C_ for columns in order to keep them together
+ * when listed in your IDE's code completion.
  * There is no need to stick to this convention but it makes life just another little bit easier.
  *
  * You may declare other database tables or views in the same way.
@@ -57,11 +58,11 @@
         {
             super("DEPARTMENTS", db);
             // ID
-            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, true, "DEP_ID_SEQUENCE");
-            NAME            = addColumn("NAME",             DataType.TEXT,         80, true);
-            HEAD            = addColumn("HEAD",             DataType.TEXT,         80, false);
-            BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, true, "ITTK");
-            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, true);
+            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, DataMode.AutoGenerated, "DEP_ID_SEQUENCE");
+            NAME            = addColumn("NAME",             DataType.TEXT,         80, DataMode.NotNull);
+            HEAD            = addColumn("HEAD",             DataType.TEXT,         80, DataMode.Nullable);
+            BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, DataMode.NotNull, "ITTK");
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, DataMode.AutoGenerated);
 
             // Primary Key
             setPrimaryKey(DEPARTMENT_ID);
@@ -94,18 +95,18 @@
         {
             super("EMPLOYEES", db);
             // ID
-            EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, true, "EMPLOYEE_ID_SEQUENCE");
-            SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, false);
-            FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, true);
-            LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, true);
-            DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, false);
-            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,      0, true);
-            GENDER          = addColumn("GENDER",           DataType.TEXT,         1, false);
-            PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, false);
-            EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, false);
-            SALARY          = addColumn("SALARY",           DataType.DECIMAL,   10.2, false);
-            RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, true, false);
-            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, true);
+            EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, DataMode.AutoGenerated, "EMPLOYEE_ID_SEQUENCE");
+            SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, DataMode.Nullable);
+            FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, DataMode.NotNull);
+            LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, DataMode.NotNull);
+            DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, DataMode.Nullable);
+            DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,      0, DataMode.NotNull);
+            GENDER          = addColumn("GENDER",           DataType.TEXT,         1, DataMode.Nullable);
+            PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, DataMode.Nullable);
+            EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, DataMode.Nullable);
+            SALARY          = addColumn("SALARY",           DataType.DECIMAL,   10.2, DataMode.Nullable);
+            RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, DataMode.NotNull, false);
+            UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, DataMode.AutoGenerated);
 
             // Primary Key
             setPrimaryKey(EMPLOYEE_ID);
@@ -129,7 +130,7 @@
     /**
      * Constructor of the SampleDB data model description
      *
-     * Put all foreigen key realtions here.
+     * Put all foreign key relations here.
      */
     public SampleDB()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java Tue Jan 26 23:34:14 2010
@@ -80,7 +80,7 @@
         // Constructor
     }
 
-    // Login requried for this action
+    // Login required for this action
     @Override
     public boolean loginRequired()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/SampleAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/SampleAction.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/SampleAction.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2-cxf/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/SampleAction.java Tue Jan 26 23:34:14 2010
@@ -40,7 +40,7 @@
         // Constructor
     }
 
-    // Login requried for this action
+    // Login required for this action
     @Override
     public boolean loginRequired()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/db/SampleDB.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/db/SampleDB.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/db/SampleDB.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/db/SampleDB.java Tue Jan 26 23:34:14 2010
@@ -20,6 +20,7 @@
 
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 import org.apache.empire.db.DBColumn;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBTableColumn;
@@ -49,11 +50,11 @@
         {
             super("DEPARTMENTS", db);
             // ID
-            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, true, "DEP_ID_SEQUENCE");
-            C_NAME            = addColumn("NAME",             DataType.TEXT,         80, true);
-            C_HEAD            = addColumn("HEAD",             DataType.TEXT,         80, false);
-            C_BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, true, "ITTK");
-            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, true);
+            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.AUTOINC,       0, DataMode.NotNull, "DEP_ID_SEQUENCE");
+            C_NAME            = addColumn("NAME",             DataType.TEXT,         80, DataMode.NotNull);
+            C_HEAD            = addColumn("HEAD",             DataType.TEXT,         80, DataMode.Nullable);
+            C_BUSINESS_UNIT   = addColumn("BUSINESS_UNIT",    DataType.TEXT,          4, DataMode.NotNull, "ITTK");
+            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,      0, DataMode.NotNull);
         
             // Primary Key
             setPrimaryKey(C_DEPARTMENT_ID);
@@ -86,17 +87,17 @@
         {
             super("EMPLOYEES", db);
             // ID
-            C_EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, true, "EMPLOYEE_ID_SEQUENCE");
-            C_SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, false);
-            C_FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, true);
-            C_LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, true);
-            C_DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, false);
-            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,      0, true);
-            C_GENDER          = addColumn("GENDER",           DataType.TEXT,         1, false);
-            C_PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, false);
-            C_EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, false);
-            C_RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, true, false);
-            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, true);
+            C_EMPLOYEE_ID     = addColumn("EMPLOYEE_ID",      DataType.AUTOINC,      0, DataMode.NotNull, "EMPLOYEE_ID_SEQUENCE");
+            C_SALUTATION      = addColumn("SALUTATION",       DataType.TEXT,        20, DataMode.Nullable);
+            C_FIRSTNAME       = addColumn("FIRSTNAME",        DataType.TEXT,        40, DataMode.NotNull);
+            C_LASTNAME        = addColumn("LASTNAME",         DataType.TEXT,        40, DataMode.NotNull);
+            C_DATE_OF_BIRTH   = addColumn("DATE_OF_BIRTH",    DataType.DATE,         0, DataMode.Nullable);
+            C_DEPARTMENT_ID   = addColumn("DEPARTMENT_ID",    DataType.INTEGER,      0, DataMode.NotNull);
+            C_GENDER          = addColumn("GENDER",           DataType.TEXT,         1, DataMode.Nullable);
+            C_PHONE_NUMBER    = addColumn("PHONE_NUMBER",     DataType.TEXT,        40, DataMode.Nullable);
+            C_EMAIL           = addColumn("EMAIL",            DataType.TEXT,        80, DataMode.Nullable);
+            C_RETIRED         = addColumn("RETIRED",          DataType.BOOL,         0, DataMode.NotNull, false);
+            C_UPDATE_TIMESTAMP= addColumn("UPDATE_TIMESTAMP", DataType.DATETIME,     0, DataMode.NotNull);
         
             // Primary Key
             setPrimaryKey(C_EMPLOYEE_ID);
@@ -119,12 +120,12 @@
         }    
     }   
 
-    // Tabellen
+    // Declare all Tables
     public final Departments  T_DEPARTMENTS = new Departments(this);
     public final Employees    T_EMPLOYEES   = new Employees(this);
     
     /**
-     * Konstruktor SampleDB
+     * Constructor SampleDB
      */
     public SampleDB()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actions/LoginAction.java Tue Jan 26 23:34:14 2010
@@ -64,7 +64,7 @@
         // Constructor
     }
 
-    // Login requried for this action
+    // Login required for this action
     @Override
     public boolean loginRequired()
     {

Modified: incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/Action.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/Action.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/Action.java (original)
+++ incubator/empire-db/trunk/empire-db-examples/empire-db-example-struts2/src/main/java/org/apache/empire/struts2/websample/web/actiontypes/Action.java Tue Jan 26 23:34:14 2010
@@ -45,7 +45,7 @@
         // Constructor
     }
 
-    // Login requried for this action
+    // Login required for this action
     @Override
     public boolean loginRequired()
     {

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/Column.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/Column.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/Column.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/Column.java Tue Jan 26 23:34:14 2010
@@ -45,6 +45,13 @@
     boolean isRequired();
 
     /**
+     * Returns whether or not the value for this column is auto-generated
+     * <P>
+     * @return Returns true if the value for this column is auto-generated
+     */
+    boolean isAutoGenerated();
+
+    /**
      * Returns true if the values for this column are generally
      * read only (like i.e. for sequence generated values).
      * <P>

Added: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java?rev=903490&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java (added)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java Tue Jan 26 23:34:14 2010
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.data;
+
+/**
+ * DataMode is an enumeration that specifies whether the value of a column is readonly, optional (nullable), required (NotNull), or auto-generated 
+ */
+public enum DataMode {
+    /**
+     * ReadOnly = value cannot be changed
+     */
+    ReadOnly, 
+    /**
+     * Optional = value may be null
+     */
+    Nullable, // i.e. Optional 
+    /**
+     * Required = value may not be null
+     */
+    NotNull, // i.e. Required
+    /**
+     * AutoGenerated = value is automatically generated by the database on inserts
+     */
+    AutoGenerated,
+}

Propchange: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java
------------------------------------------------------------------------------
    eol-style = native

Propchange: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataMode.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataType.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataType.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataType.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/DataType.java Tue Jan 26 23:34:14 2010
@@ -71,7 +71,7 @@
     DECIMAL, //      = 8;
     
     /**
-     * Boolean field (emulated if not supported by dbms as number or char)
+     * Boolean field (emulated if not supported by DBMS as number or char)
      */
     BOOL, //         = 9;
     
@@ -84,4 +84,9 @@
      * Binary data
      */
     BLOB, //         = 11;
+    
+    /**
+     * Unique Identifier (non-numeric, treated like text) 
+     */
+    UNIQUEID, //     = 12;
 }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanClass.java Tue Jan 26 23:34:14 2010
@@ -23,13 +23,14 @@
 
 import org.apache.empire.data.Column;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 
 
 /**
  * BeanObject
  * This class defines Metadata for any type of java class.
  * For each class you want to describe create one Metadata class and derive it from BeanClass.
- * A metadata defintion consitst primarily of the class name and a list of properties.  
+ * A metadata definition consists primarily of the class name and a list of properties.  
  * @author Rainer
  */
 public abstract class BeanClass
@@ -57,6 +58,21 @@
         prop.beanClass = this;
     }
 
+    protected final BeanProperty addProp(String propname, DataType dataType, double size, DataMode dataMode)
+    {
+        BeanProperty prop = new BeanProperty(propname, dataType, size, dataMode, "text");
+        addProp(prop);
+        return prop;
+    }
+
+    protected final BeanProperty addProp(String propname, DataType dataType, double size, DataMode dataMode, String controlType)
+    {
+        BeanProperty prop = new BeanProperty(propname, dataType, size, dataMode, controlType);
+        addProp(prop);
+        return prop;
+    }
+
+    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, "text", false);
@@ -64,6 +80,7 @@
         return prop;
     }
 
+    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required, String controlType)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType, false);
@@ -71,6 +88,7 @@
         return prop;
     }
 
+    @Deprecated
     protected final BeanProperty addProp(String propname, DataType dataType, double size, boolean required, String controlType, boolean readOnly)
     {
         BeanProperty prop = new BeanProperty(propname, dataType, size, required, controlType, readOnly);

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanDomain.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanDomain.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanDomain.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanDomain.java Tue Jan 26 23:34:14 2010
@@ -26,7 +26,7 @@
  * This class defines Metadata for a domain of java classes.
  * Create a new class for your domain metadata and derive it from BeanDomain.
  * Then create a BeanClass subclass (preferably as a nested class) for each of your domain objects.
- * A metadata defintion consitst primarily of the domain name and a list of classes.  
+ * A metadata definition consists primarily of the domain name and a list of classes.  
  * @author Rainer
  */
 public abstract class BeanDomain

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanProperty.java Tue Jan 26 23:34:14 2010
@@ -22,6 +22,7 @@
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.Column;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 
 /**
  * BeanObject
@@ -32,11 +33,10 @@
 {
     private final String   name;
     private final DataType dataType;
+    private final DataMode dataMode;
     private final double   size;
-    private final boolean  required;
     
     private String   controlType; // optional (default is 'text')
-    private boolean  readOnly;    // optional
     private String   title;       // optional
     private Options  options;     // optional
     private Attributes attributes;// optional
@@ -45,19 +45,51 @@
     
     // --- ColumnExpr interface implementation ---
     
-    public BeanProperty(String name, DataType dataType, double size, boolean required, String controlType, boolean readOnly)
+    /**
+     * Constructs a bean property definition
+     * @param name the name of the property (case insensitive)
+     * @param dataType the data type
+     * @param size size depending on data type. For data type TEXT the maximum number of characters.
+     * @param dataMode determines whether this property is read only, optional, required or auto-generated 
+     * @param controlType the control type to be used for editing this value. Depends on the client. Default is "text"
+     */
+    public BeanProperty(String name, DataType dataType, double size, DataMode dataMode, String controlType)
     {
         this.name = name;
         this.dataType = dataType;
         this.size = size;
-        this.required = required;
+        this.dataMode = dataMode;
         this.controlType = controlType;
-        this.readOnly = readOnly;
+    }
+
+    /**
+     * @deprecated use BeanProperty(String name, DataType dataType, double size, DataMode dataMode, String controlType) instead.
+     * @param name
+     * @param dataType
+     * @param size
+     * @param required
+     * @param controlType
+     * @param readOnly
+     */
+    @Deprecated
+    public BeanProperty(String name, DataType dataType, double size, boolean required, String controlType, boolean readOnly)
+    {
+        this(name, dataType, size, (readOnly ? DataMode.ReadOnly : (required ? DataMode.NotNull : DataMode.Nullable)), controlType);
     }
     
+    /**
+     * @deprecated use BeanProperty(String name, DataType dataType, double size, DataMode dataMode, String controlType) instead.
+     * @param name
+     * @param dataType
+     * @param size
+     * @param required
+     * @param controlType
+     * @param readOnly
+     */
+    @Deprecated
     public BeanProperty(String name, DataType dataType, double size, boolean required)
     {
-        this(name, dataType, size, required, "text", false);
+        this(name, dataType, size, (required ? DataMode.NotNull : DataMode.Nullable), "text");
     }
 
     /**
@@ -155,12 +187,17 @@
 
     public boolean isReadOnly()
     {
-        return readOnly;
+        return (dataMode==DataMode.ReadOnly || dataMode==DataMode.AutoGenerated);
+    }
+
+    public boolean isAutoGenerated()
+    {
+        return (dataMode==DataMode.AutoGenerated);
     }
 
     public boolean isRequired()
     {
-        return required;
+        return (dataMode==DataMode.NotNull);
     }
 
     // --- others ---

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/data/bean/BeanRecordProxy.java Tue Jan 26 23:34:14 2010
@@ -33,7 +33,6 @@
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.Column;
 import org.apache.empire.data.ColumnExpr;
-import org.apache.empire.data.DataType;
 import org.apache.empire.data.Record;
 
 
@@ -156,7 +155,7 @@
     {
     	if (isNew()==false && ObjectUtils.contains(keyColumns, column))
     		return true;
-    	if (column.getDataType()==DataType.AUTOINC)
+    	if (column.isAutoGenerated())
     		return true;
         return column.isReadOnly();
     }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumn.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumn.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBColumn.java Tue Jan 26 23:34:14 2010
@@ -97,6 +97,13 @@
      * @return Returns true if the column is required
      */
     public abstract boolean isRequired();
+    
+    /**
+     * Returns true if column is a columns value is an automatically generated value
+     * 
+     * @return true if column is auto-generated
+     */
+    public abstract boolean isAutoGenerated();
 
     /**
      * Returns true if the column is read-only.

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBCommandExpr.java Tue Jan 26 23:34:14 2010
@@ -217,6 +217,15 @@
         }
 
         /**
+         * Not applicable - always returns false
+         */
+        @Override
+        public boolean isAutoGenerated()
+        {
+            return false; // expr.isReadOnly();
+        }
+
+        /**
          * Checks whether the column is mandatory.
          * 
          * @return true if the column is mandatory or false otherwise

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBDatabaseDriver.java Tue Jan 26 23:34:14 2010
@@ -32,11 +32,13 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.empire.commons.DateUtils;
 import org.apache.empire.commons.ErrorObject;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 
 
 /**
@@ -143,14 +145,14 @@
         {
             super(tableName, db);
             // Add all Colums
-            C_SEQNAME   = addColumn("SeqName",  DataType.TEXT,      40, true);
-            C_SEQVALUE  = addColumn("SeqValue", DataType.INTEGER,    0, true);
-            C_TIMESTAMP = addColumn("SeqTime",  DataType.DATETIME,   0, true);
+            C_SEQNAME   = addColumn("SeqName",  DataType.TEXT,      40, DataMode.NotNull);
+            C_SEQVALUE  = addColumn("SeqValue", DataType.INTEGER,    0, DataMode.NotNull);
+            C_TIMESTAMP = addColumn("SeqTime",  DataType.DATETIME,   0, DataMode.NotNull);
             // Primary Key
             setPrimaryKey(new DBColumn[] { C_SEQNAME });
         }
 
-        // Overridables
+        // Overrideable
         public Object getNextValue(String SeqName, long minValue, Connection conn)
         {
             DBDatabaseDriver driver = db.getDriver();
@@ -187,11 +189,11 @@
                     else
                     { // Close Reader
                         db.closeResultSet(rs);
-                        // neu angelegen!
+                        // sequence does not exist
                         seqValue = minValue;
                         log.warn("warn: Sequence '" + SeqName
                                        + "' does not exist! Creating sequence with start-value of " + seqValue);
-                        // Add a new Sequence
+                        // create a new sequence entry
                         cmd.clear();
                         cmd.set(C_SEQNAME.to(SeqName));
                         cmd.set(C_SEQVALUE.to(seqValue));
@@ -199,7 +201,7 @@
                         if (db.executeSQL(cmd.getInsert(), null, conn) < 1)
                             seqValue = 0; // Try again
                     }
-                    // concurreny problem?
+                    // check for concurrency problem
                     if (seqValue == 0)
                         log.warn("Failed to increment sequence '" + SeqName + "'. Trying again!");
                     // close
@@ -335,6 +337,38 @@
     public abstract Object getNextSequenceValue(DBDatabase db, String SeqName, int minValue, Connection conn);
 
     /**
+     * Returns an auto-generated value for a particular column
+     * 
+     * @param db the database
+     * @param column the column for which a value is required
+     * @param conn a valid database connection
+     * @return the auto-generated value
+     */
+    public Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
+    {
+        // Supports sequences?
+        DataType type = column.getDataType();
+        if (type == DataType.AUTOINC)
+        {   // Use a numeric sequence
+            if (isSupported(DBDriverFeature.SEQUENCES)==false)
+                return null; // Create Later
+            // Detect the Sequence Name
+            Object defValue= column.getDefaultValue();
+            String SeqName = (defValue != null) ? defValue.toString() : this.toString();
+            return db.getNextSequenceValue(SeqName, conn);
+        }
+        // Set database systems time and date
+        if ((type==DataType.DATE || type==DataType.DATETIME))
+        {   // Get database system's date and time
+            Date ts = db.getUpdateTimestamp(conn);
+            return (type==DataType.DATE ? DateUtils.getDateOnly(ts) : ts);
+        }
+        // Other types
+        error(Errors.NotSupported, "getColumnAutoValue() for "+String.valueOf(type));
+        return null;
+    }
+
+    /**
      * Prepares an sql statement by setting the supplied objects as parameters.
      * 
      * @param pstmt the prepared statement
@@ -495,7 +529,7 @@
             throw e;
         }
     }
-
+    
     // close
     protected void close(Statement stmt)
     {
@@ -569,6 +603,7 @@
             case TEXT:
             case CHAR:
             case CLOB:
+            case UNIQUEID:
             {   // Text value
                 StringBuilder valBuf = new StringBuilder();
                 valBuf.append("'");

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBQuery.java Tue Jan 26 23:34:14 2010
@@ -90,6 +90,15 @@
         }
 
         @Override
+        public boolean isAutoGenerated()
+        {
+            DBColumn column = expr.getUpdateColumn();
+            if (column==null)
+                return false;
+            return column.isAutoGenerated();
+        }
+
+        @Override
         public boolean isRequired()
         {
             DBColumn column = expr.getUpdateColumn();

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecord.java Tue Jan 26 23:34:14 2010
@@ -32,7 +32,6 @@
 import org.apache.empire.commons.Options;
 import org.apache.empire.data.Column;
 import org.apache.empire.data.ColumnExpr;
-import org.apache.empire.data.DataType;
 import org.apache.empire.data.Record;
 import org.apache.empire.xml.XMLUtil;
 import org.w3c.dom.Document;
@@ -518,7 +517,7 @@
             return success(); // no change
         // Field has changed
         DBColumn column = rowset.getColumn(i);
-        if (column.getDataType()==DataType.AUTOINC)
+        if (column.isAutoGenerated())
         {   // Read Only column may be set
             return error(DBErrors.FieldIsReadOnly, column.getName());
         }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Tue Jan 26 23:34:14 2010
@@ -40,7 +40,7 @@
 /**
  * This class is the base class for all the DBTable,
  * CBView and DBQuery classes this class contains all the columns of the
- * tables, views or querys
+ * tables, views or queries
  * <P>
  * 
  *
@@ -646,39 +646,42 @@
 
             case DBRecord.REC_NEW:
                 for (int i = 0; i < columns.size(); i++)
-                { // search for the column
+                {   // search for the column
                 	Object value = fields[i];
-                	boolean empty = ObjectUtils.isEmpty(value); 
                     DBTableColumn col = (DBTableColumn) columns.get(i);
-                    if (col.getDataType()==DataType.AUTOINC && empty) 
-                    { // Set Autoinc value if not already done
-                        if (db.getDriver().isSupported(DBDriverFeature.SEQUENCES)==false)
-                        {  // Post Dectect Autoinc Value
+                    if (timestampColumn == col)
+                    {   // Make sure the update timestamp column is set
+                        cmd.set(col.to(timestamp));
+                        continue;
+                    } 
+                    boolean empty = ObjectUtils.isEmpty(value); 
+                    if (empty && col.isAutoGenerated()) 
+                    {   // Check for AutoInc data type
+                        if (col.getDataType()==DataType.AUTOINC && 
+                            db.getDriver().isSupported(DBDriverFeature.SEQUENCES)==false)
+                        {  // Obtain value via JDBC Statement.RETURN_GENERATED_KEYS
                            setGenKey = new DBSetGenKey(fields, i);
                            continue;
                         }
-                        // Get Next Sequence value
+                        // get the auto-generated field value
                         fields[i] = value = col.getRecordDefaultValue(conn);
                         empty = ObjectUtils.isEmpty(value);
                     }
-                    if (primaryKey!=null && primaryKey.contains(col) && empty)
-                    { // All primary key fields must be supplied
-                        return error(DBErrors.FieldNotNull, col.getTitle());
-                    }
-                    if (timestampColumn == col)
-                    { // Make sure the upate Timestamp Column is set
-                        cmd.set(col.to(timestamp));
-                    } 
-                    else if (empty==false)
-                    { // Check the value
-                        if (!col.checkValue(value))
+                    // Add the value to the command
+                    if (empty==false)
+                    {   // Check the value
+                        if (!col.isAutoGenerated() && !col.checkValue(value))
                             return error(col);
                         // Insert a field
                         cmd.set(col.to(value));
                         setCount++;
-                    } 
-                    else if (col.required == true)
-                    { // Error Column is required!
+                    }
+                    else if (primaryKey!=null && primaryKey.contains(col))
+                    {   // All primary key fields must be supplied
+                        return error(DBErrors.FieldNotNull, col.getTitle());
+                    }
+                    else if (col.isRequired())
+                    {   // Error Column is required!
                         return error(DBErrors.FieldNotNull, col.getTitle());
                     }
                 }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTable.java Tue Jan 26 23:34:14 2010
@@ -27,11 +27,12 @@
 
 import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 
 
 /**
  * This class represent one table of the database.
- * It consits methods to get, add, update and delete records from the database.
+ * It contains methods to get, add, update and delete records from the database.
  * <P>
  * 
  *
@@ -157,17 +158,48 @@
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
      * @param size the column width
+     * @param dataMode determines whether this column is optional, required or auto-generated 
+     * @param defValue a Object object
+     * @return the created DBTableColumn object
+     */
+    public final DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode, Object defValue)
+    { 
+        return new DBTableColumn(this, type, columnName, size, dataMode, defValue);
+    }
+
+    /**
+     * Creates a new DBTableColumn object and add it to this object.
+     * 
+     * @param columnName the column name
+     * @param type the type of the column e.g. integer, text, date
+     * @param size the column width
+     * @param dataMode determines whether this column is optional, required or auto-generated 
+     * @return the created DBTableColumn object
+     */
+    public final DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode)
+    { 
+        return new DBTableColumn(this, type, columnName, size, dataMode, null);
+    }
+
+    /**
+     * deprecated use DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode, Object defValue) instead
+     * 
+     * @param columnName the column name
+     * @param type the type of the column e.g. integer, text, date
+     * @param size the column width
      * @param required true if not null column
      * @param defValue a Object object
      * @return the created DBTableColumn object
      */
+    // @Deprecated
+    @SuppressWarnings("deprecation")
     public final DBTableColumn addColumn(String columnName, DataType type, double size, boolean required, Object defValue)
-    { // find column by name
+    { 
         return new DBTableColumn(this, type, columnName, size, required, defValue);
     }
 
     /**
-     * Creates a new DBTableColumn object and add it to this object.
+     * deprecated use DBTableColumn addColumn(String columnName, DataType type, double size, DataMode dataMode) instead
      * 
      * @param columnName the column name
      * @param type the type of the column e.g. integer, text, date
@@ -175,9 +207,11 @@
      * @param required true if not null column
      * @return the created DBTableColumn object
      */
+    // @Deprecated
+    @SuppressWarnings("deprecation")
     public final DBTableColumn addColumn(String columnName, DataType type, double size, boolean required)
-    { // find column by name
-        return addColumn(columnName, type, size, required, null);
+    { 
+        return new DBTableColumn(this, type, columnName, size, required, null);
     }
 
     /**
@@ -205,7 +239,7 @@
      * 
      * @param columns a array with one or more DBColumn objects
      * 
-     * @return true on succes
+     * @return true on success
      */
     public boolean setPrimaryKey(DBColumn[] columns)
     {
@@ -260,7 +294,7 @@
      * @param unique is this a unique index
      * @param indexColumns the columns indexed by this index
      * 
-     * @return true on succes
+     * @return true on success
      */
     public boolean addIndex(String indexName, boolean unique, DBColumn[] indexColumns)
     {
@@ -280,7 +314,7 @@
      */
     public DBTableColumn addTimestampColumn(String columnName)
     {
-        DBTableColumn col = addColumn(columnName, DataType.DATETIME, 0, true, DBDatabase.SYSDATE);
+        DBTableColumn col = addColumn(columnName, DataType.DATETIME, 0, DataMode.AutoGenerated, DBDatabase.SYSDATE);
         setTimestampColumn(col);
         return col;
     }

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java Tue Jan 26 23:34:14 2010
@@ -25,8 +25,9 @@
 import java.util.Date;
 
 import org.apache.empire.commons.Attributes;
-import org.apache.empire.commons.DateUtils;
+import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataType;
+import org.apache.empire.data.DataMode;
 import org.apache.empire.xml.XMLUtil;
 import org.w3c.dom.Element;
 
@@ -43,7 +44,7 @@
     // Column Information
     protected DataType  type;
     protected double    size;
-    protected boolean   required;
+    protected DataMode  dataMode;
     protected Object    defValue;
 
     /**
@@ -53,15 +54,22 @@
      * @param type the type of the column e.g. integer, text, date
      * @param name the column name
      * @param size the column width
-     * @param required true if not null column
+     * @param dataMode determines whether this column is optional, required or auto-generated 
      * @param defValue the object value
      */
-    public DBTableColumn(DBTable table, DataType type, String name, double size, boolean required, Object defValue)
+    public DBTableColumn(DBTable table, DataType type, String name, double size, DataMode dataMode, Object defValue)
     {
         super(table, name);
+        // check properties
+        // Make sure (DataType.INTEGER & DataMode.AutoGenerated) = DataType.AUTOINC
+        if (type==DataType.AUTOINC && dataMode!=DataMode.AutoGenerated)
+            dataMode=DataMode.AutoGenerated;
+        if (type==DataType.INTEGER && dataMode==DataMode.AutoGenerated)
+            type=DataType.AUTOINC;
+        // set column properties
         this.type = type;
         this.size = size;
-        this.required = required;
+        this.dataMode = dataMode;
         this.defValue = defValue;
         // xml
         attributes = new Attributes();
@@ -72,6 +80,22 @@
     }
 
     /**
+     * @deprecated use DBTableColumn(DBTable table, DataType type, String name, double size, DataMode dataMode, Object defValue) instead 
+     * 
+     * @param table the table object to add the column to, set to null if you don't want it added to a table
+     * @param type the type of the column e.g. integer, text, date
+     * @param name the column name
+     * @param size the column width
+     * @param required true if not null column
+     * @param defValue the object value
+     */
+    @Deprecated
+    public DBTableColumn(DBTable table, DataType type, String name, double size, boolean required, Object defValue)
+    {
+        this(table, type, name, size, (required ? DataMode.NotNull : DataMode.Nullable), defValue);
+    }
+
+    /**
      * Clone Constructor - use clone()
      */
     protected DBTableColumn(DBTable newTable, DBTableColumn other)
@@ -80,7 +104,7 @@
         // Copy
         this.type = other.type;
         this.size = other.size;
-        this.required = other.required;
+        this.dataMode = other.dataMode;
         this.defValue = other.defValue;
         attributes = other.attributes;
         options = other.options;
@@ -88,7 +112,7 @@
         if (newTable != null)
             newTable.addColumn(this);
     }
-
+    
     /**
      * Returns the default column value.
      * For columns of type DBDataType.AUTOINC this is assumed to be the name of a sequence
@@ -112,7 +136,7 @@
     
     /**
      * Returns the default column value. 
-     * Unklike getDefaultValue this function is used when creating or adding records.
+     * Unlike getDefaultValue this function is used when creating or adding records.
      * If the column value is DBDataType AUTOIN this function will return a new sequence value for this record
      * 
      * @param conn a valid database connection
@@ -124,25 +148,13 @@
             return defValue;
         // Detect default value
         DBDatabase db = rowset.getDatabase();
-        if (type == DataType.AUTOINC)
-        {   // If no connectoin is supplied defer till later
+        if (isAutoGenerated())
+        {   // If no connection is supplied defer till later
         	if (conn==null)
         		return null; // Create Later
-            // Supports sequences?
-            if (db.getDriver().isSupported(DBDriverFeature.SEQUENCES)==false)
-                return null; // Create Later
-        	// Detect the Sequence Name
-            String SeqName = (defValue != null) ? defValue.toString() : this.toString();
-            return db.getNextSequenceValue(SeqName, conn);
-        }
-        // Set database systems time and date
-        if ((type==DataType.DATE || type==DataType.DATETIME) && DBDatabase.SYSDATE.equals(defValue))
-        { 	// If no connection is supplied defer till later
-        	if (conn==null)
-        		return defValue;
-        	// Get database system's date and time
-	        Date ts = db.getUpdateTimestamp(conn);
-	        return (type==DataType.DATE ? DateUtils.getDateOnly(ts) : ts);
+            // Other auto-generated values
+        	DBDatabaseDriver driver = db.getDriver();
+            return driver.getColumnAutoValue(db, this, conn);
         }
         // Normal value
         return defValue;
@@ -188,17 +200,34 @@
     @Override
     public boolean isRequired()
     {
-        return required;
+        return (dataMode==DataMode.NotNull);
+    }
+    
+    /**
+     * Returns true if column is a numeric sequence or otherwise generated value
+     * 
+     * @return true if column is auto increment
+     */
+    @Override
+    public boolean isAutoGenerated()
+    {
+        return (dataMode==DataMode.AutoGenerated);
     }
 
     /**
-     * Changes the requied property of the table column<BR>
+     * Changes the required property of the table column<BR>
      * Use for dynamic data model changes only.<BR>
-     * @param required true if the column is requried or false otherwise
+     * @param required true if the column is required or false otherwise
      */
     public void setRequired(boolean required)
     {
-        this.required = required;
+        if (isAutoGenerated())
+        {   // cannot change auto-generated columns
+            error(Errors.NoAccess);
+            return; 
+        }
+        // Set DataMode
+        dataMode=(required ? DataMode.NotNull : DataMode.Nullable);
     }
 
     /**
@@ -212,8 +241,8 @@
         if (attributes!=null &&
             attributes.containsKey(DBCOLATTR_READONLY))
             return true;
-        // AUTOINC's are read only
-        return (type == DataType.AUTOINC);
+        // Check DataMode
+        return (dataMode==DataMode.ReadOnly || dataMode==DataMode.AutoGenerated);
     }
 
     /**
@@ -244,8 +273,9 @@
      */
     @Override
     public boolean checkValue(Object value)
-    { // Is Value valid
-        if (required && (value == null || value.toString().length() < 1))
+    {
+        // Check for NULL
+        if (isRequired() && (value == null || value.toString().length() < 1))
             return error(DBErrors.FieldNotNull, getTitle());
         // Is value valid
         switch (type)
@@ -269,6 +299,7 @@
                 break;
 
             case DECIMAL:
+            case DOUBLE:
                 if (value!=null && (value instanceof java.lang.Number)==false)
                 {   try
                     {   // Convert to String and check
@@ -290,8 +321,8 @@
                     {   // Convert to String and check
                         String val = value.toString();
                         if (val.length() > 0)
-                            Integer.parseInt(val);
-                        // thows NumberFormatException if not an integer!
+                            Long.parseLong(val);
+                        // throws NumberFormatException if not an integer!
                     } catch (NumberFormatException nfe)
                     {
                         log.error("checkValue exception: " + nfe.toString() + " column=" + getTitle() + " value=" + String.valueOf(value));
@@ -327,7 +358,7 @@
     }
 
     /**
-     * Sets field elements, default attributes and all otions to
+     * Sets field elements, default attributes and all options to
      * the specified Element object (XML tag).
      * 
      * @param parent the parent object
@@ -353,7 +384,7 @@
             if (getDataType()==DataType.DECIMAL)
                 elem.setAttribute("decimals", String.valueOf((int)(size*10)%10));
         }
-        if (required)
+        if (isRequired())
             elem.setAttribute(DBCOLATTR_MANDATORY, String.valueOf(Boolean.TRUE));
         // add All Attributes
         if (attributes!=null)

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBView.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBView.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBView.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBView.java Tue Jan 26 23:34:14 2010
@@ -30,11 +30,9 @@
 
 
 /**
- * This class represent a view of the database.
- * It consits methods to get and update records from the database
+ * This class represents a database view.
+ * It contains methods to get and update records from the database
  * <P>
- * 
- *
  */
 public abstract class DBView extends DBRowSet
 {
@@ -81,6 +79,14 @@
                 return 0.0;
             return updateColumn.getSize();
         }
+        
+        @Override
+        public boolean isAutoGenerated()
+        {
+            if (updateColumn==null)
+                return false;
+            return updateColumn.isAutoGenerated();
+        }
 
         @Override
         public boolean isReadOnly()
@@ -92,7 +98,7 @@
                 attributes.containsKey(DBCOLATTR_READONLY))
                 return true;
             // AUTOINC's are read only
-            return (getDataType() == DataType.AUTOINC);
+            return isAutoGenerated();
         }
 
         @Override

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/derby/DBDatabaseDriverDerby.java Tue Jan 26 23:34:14 2010
@@ -491,7 +491,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -591,13 +591,12 @@
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
-        {   
-            sql.append(" DEFAULT ");
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
+        {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/h2/DBDatabaseDriverH2.java Tue Jan 26 23:34:14 2010
@@ -488,7 +488,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -576,12 +576,12 @@
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/hsql/DBDatabaseDriverHSql.java Tue Jan 26 23:34:14 2010
@@ -471,7 +471,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -546,12 +546,12 @@
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/mysql/DBDatabaseDriverMySQL.java Tue Jan 26 23:34:14 2010
@@ -515,7 +515,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -603,12 +603,12 @@
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/oracle/DBDatabaseDriverOracle.java Tue Jan 26 23:34:14 2010
@@ -559,7 +559,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -636,12 +636,12 @@
                 return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;
@@ -811,9 +811,9 @@
 
     
     /**
-     * Checks whether the database defintion matches the real database structure.
+     * Checks whether the database definition matches the real database structure.
      * 
-     * @return true if the database defintion matches the real database structure.
+     * @return true if the database definition matches the real database structure.
      */
     @Override
     public boolean checkDatabase(DBDatabase db, String owner, Connection conn)

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java Tue Jan 26 23:34:14 2010
@@ -630,7 +630,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @param alter is this for an alter statement
@@ -725,12 +725,12 @@
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/sqlserver/DBDatabaseDriverMSSQL.java Tue Jan 26 23:34:14 2010
@@ -300,7 +300,7 @@
                 return "?";
         }
     }
-    
+
     /**
      * @see DBDatabaseDriver#getNextSequenceValue(DBDatabase, String, int, Connection)
      */
@@ -319,6 +319,25 @@
     }
 
     /**
+     * Returns an auto-generated value for a particular column
+     * 
+     * @param db the database
+     * @param column the column for which a value is required
+     * @param conn a valid database connection
+     * @return the auto-generated value
+     */
+    @Override
+    public Object getColumnAutoValue(DBDatabase db, DBTableColumn column, Connection conn)
+    {
+        // Supports sequences?
+        if (column.getDataType()==DataType.UNIQUEID)
+        {
+            return db.querySingleValue("select newid()", conn);
+        }
+        return super.getColumnAutoValue(db, column, conn);
+    }
+
+    /**
      * @see DBDatabaseDriver#getDDLScript(DBCmdType, DBObject, DBSQLScript)  
      */
     @Override
@@ -415,7 +434,7 @@
             script.addStmt("USE " + databaseName);
             script.addStmt("SET DATEFORMAT ymd");
             // Sequence Table
-            if (db.getTable(sequenceTableName)==null)
+            if (useSequenceTable && db.getTable(sequenceTableName)==null)
                 new DBSeqTable(sequenceTableName, db);
         }
         // Create all Tables
@@ -525,7 +544,7 @@
     }
     
     /**
-     * Appends a table column defintion to a ddl statement
+     * Appends a table column definition to a ddl statement
      * @param c the column which description to append
      * @param sql the sql builder object
      * @return true if the column was successfully appended or false otherwise
@@ -603,17 +622,22 @@
                 if (c.getSize() > 0)
                     sql.append(" (" + String.valueOf((long) c.getSize()) + ") ");
                 break;
+            case UNIQUEID:
+                sql.append("[uniqueidentifier]");
+                if (c.isAutoGenerated())
+                    sql.append(" ROWGUIDCOL");
+                break;
             case UNKNOWN:
                  log.error("Cannot append column of Data-Type 'UNKNOWN'");
                  return false;
         }
         // Default Value
-        if (isDDLColumnDefaults() && c.getDataType()!=DataType.AUTOINC && c.getDefaultValue()!=null)
+        if (isDDLColumnDefaults() && !c.isAutoGenerated() && c.getDefaultValue()!=null)
         {   sql.append(" DEFAULT ");
             sql.append(getValueString(c.getDefaultValue(), c.getDataType()));
         }
         // Nullable
-        if (c.isRequired())
+        if (c.isRequired() ||  c.isAutoGenerated())
             sql.append(" NOT NULL");
         // Done
         return true;

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java?rev=903490&r1=903489&r2=903490&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java (original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/xml/XMLWriter.java Tue Jan 26 23:34:14 2010
@@ -386,7 +386,6 @@
      * @param attrs the unsorted list of attributes
      * @return the sorted list of attributes
      */
-    @SuppressWarnings("null")
     protected Attr[] sortAttributes(NamedNodeMap attrs)
     {
 
@@ -431,7 +430,6 @@
         return normalize(s, canonical);
     }
 
-    @SuppressWarnings({ "fallthrough", "null" })
     static public String normalize(String s, boolean canonical)
     {
         StringBuilder str = new StringBuilder();



Mime
View raw message