empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1148444 [2/4] - in /incubator/empire-db/branches/EMPIREDB-99/empire-db/src: main/java/org/apache/empire/ main/java/org/apache/empire/commons/ main/java/org/apache/empire/data/ main/java/org/apache/empire/data/bean/ main/java/org/apache/emp...
Date Tue, 19 Jul 2011 16:53:41 GMT
Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBQuery.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBQuery.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBQuery.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBQuery.java Tue Jul 19 16:53:34 2011
@@ -18,6 +18,13 @@
  */
 package org.apache.empire.db;
 
+import java.sql.Connection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.Options;
@@ -28,12 +35,6 @@ import org.apache.empire.db.expr.compare
 import org.apache.empire.db.expr.join.DBJoinExpr;
 import org.w3c.dom.Element;
 
-import java.sql.Connection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.atomic.AtomicInteger;
-
 
 /**
  * This class can be used to wrap a query from a DBCommand and use it like a DBRowSet.<BR>
@@ -112,12 +113,12 @@ public class DBQuery extends DBRowSet
         }
 
         @Override
-        public boolean checkValue(Object value)
+        public void checkValue(Object value)
         {
             DBColumn column = expr.getUpdateColumn();
             if (column==null)
-                return true;
-            return column.checkValue(value);
+                return;
+            column.checkValue(value);
         }
 
         @Override
@@ -270,10 +271,7 @@ public class DBQuery extends DBRowSet
     public Object[] getRecordKey(DBRecord record)
     {
         if (record == null || record.getRowSet() != this)
-        {
-            error(Errors.InvalidArg, record, "record");
-            return null; // Invalid Argument
-        }
+            throw new EmpireException(Errors.InvalidArg, record, "record");
         // get Key
         return (Object[]) record.getRowSetData();
     }
@@ -307,11 +305,10 @@ public class DBQuery extends DBRowSet
      * @return true if successful
      */
     @Override
-    public boolean initRecord(DBRecord rec, Object[] keyValues)
+    public void initRecord(DBRecord rec, Object[] keyValues)
     {
-        // Inititialisierung
-        if (!prepareInitRecord(rec, DBRecord.REC_EMTPY, keyValues))
-            return false;
+        // Prepare
+        prepareInitRecord(rec, DBRecord.REC_EMTPY, keyValues);
         // Initialize all Fields
         Object[] fields = rec.getFields();
         for (int i = 0; i < fields.length; i++)
@@ -325,38 +322,38 @@ public class DBQuery extends DBRowSet
                     fields[columns.indexOf(keyColumns[i])] = keyValues[i];
         }
         // Init
-        return completeInitRecord(rec);
+        completeInitRecord(rec);
     }
     
     /**
-     * Returns an error, because querys could't add new records to the database.
+     * Returns an error, because it is not possible to add a record to a query.
      * 
      * @param rec the DBRecord object, contains all fields and the field properties
      * @param conn a valid database connection
-     * @return an error, because querys could't add new records to the database
+     * @return a not implemented error
      */
     @Override
-    public boolean createRecord(DBRecord rec, Connection conn)
+    public void createRecord(DBRecord rec, Connection conn)
     {
-        return error(Errors.NotImplemented, "addRecord");
+        throw new EmpireException(Errors.NotImplemented, "createRecord");
     }
 
     /**
      * Creates a select SQL-Command of the query call the InitRecord method to execute the SQL-Command.
      * 
-     * @param rec rec the DBRecord object, contains all fields and the field properties
+     * @param rec the DBRecord object, contains all fields and the field properties
      * @param key an array of the primary key columns
      * @param conn a valid connection to the database.
      * @return true if successful
      */
     @Override
-    public boolean readRecord(DBRecord rec, Object[] key, Connection conn)
+    public void readRecord(DBRecord rec, Object[] key, Connection conn)
     {
         if (conn == null || rec == null)
-            return error(Errors.InvalidArg, null, "conn|rec");
+            throw new EmpireException(Errors.InvalidArg, null, "conn|rec");
         DBColumn[] keyColumns = getKeyColumns();
         if (key == null || keyColumns.length != key.length)
-            return error(DBErrors.RecordInvalidKey, key);
+            throw new EmpireException(DBErrors.RecordInvalidKey, key);
         // Select
         for (int i = 0; i < keyColumns.length; i++)
         {   // Set key column constraint
@@ -366,16 +363,20 @@ public class DBQuery extends DBRowSet
             cmd.where(keyColumns[i].is(value));
         }    
         // Read Record
-        if (!readRecord(rec, cmd, conn))
-        { // Record not found
-            if (getErrorType() == DBErrors.QueryNoResult)
-                return error(DBErrors.RecordNotFound, key);
-            // Return given error
-            return false;
-        }
-        // Set RowSetData
-        rec.changeState(DBRecord.REC_VALID, key.clone());
-        return success();
+        try {
+            // Read Record
+            readRecord(rec, cmd, conn);
+            // Set RowSetData
+            rec.changeState(DBRecord.REC_VALID, key.clone());
+        } catch (EmpireException e) {
+            // Translate exception
+            if (e.getErrorType()==DBErrors.QueryNoResult)
+                // Record not found
+                throw new EmpireException(DBErrors.RecordNotFound, key);
+            else
+                // Other error
+                throw e;
+        }
     }
 
     /**
@@ -383,20 +384,20 @@ public class DBQuery extends DBRowSet
      * 
      * @param rec the DBRecord object. contains all fields and the field properties
      * @param conn a valid connection to the database.
-     * @return true if succesfull
+     * @return true if successful
      */
     @Override
-    public boolean updateRecord(DBRecord rec, Connection conn)
+    public void updateRecord(DBRecord rec, Connection conn)
     {
         if (conn == null || rec == null)
-            return error(Errors.InvalidArg, null, "conn|rec");
+            throw new EmpireException(Errors.InvalidArg, null, "conn|rec");
         // Has record been modified?
         if (rec.isModified() == false)
-            return success(); // Nothing to update
+            return; // Nothing to update
         // Must have key Columns
         DBColumn[] keyColumns = getKeyColumns();
         if (keyColumns==null)
-            return error(DBErrors.NoPrimaryKey, getAlias());
+            throw new EmpireException(DBErrors.NoPrimaryKey, getAlias());
         // Get the fields and the flags
         Object[] fields = rec.getFields();
         // Get all Update Commands
@@ -423,8 +424,7 @@ public class DBQuery extends DBRowSet
                 if (col.isReadOnly() && log.isDebugEnabled())
                     log.debug("updateRecord: Read-only column '" + col.getName() + " has been modified!");
                 // Check the value
-                if (!col.checkValue(fields[i]))
-                    return error(col);
+                col.checkValue(fields[i]);
                 // Set
                 updCmd.set(col.to(fields[i]));
             }
@@ -450,10 +450,10 @@ public class DBQuery extends DBRowSet
                 DBColumn right = join.getRight().getUpdateColumn();
                 if (left.getRowSet()==table && table.isKeyColumn(left))
                     if (!addJoinRestriction(upd, left, right, keyColumns, rec))
-                        return error(Errors.ItemNotFound, left.getFullName());
+                        throw new EmpireException(Errors.ItemNotFound, left.getFullName());
                 if (right.getRowSet()==table && table.isKeyColumn(right))
                     if (!addJoinRestriction(upd, right, left, keyColumns, rec))
-                        return error(Errors.ItemNotFound, right.getFullName());
+                        throw new EmpireException(Errors.ItemNotFound, right.getFullName());
             }
             // Evaluate Existing restrictions
             for (i = 0; cmd.where != null && i < cmd.where.size(); i++)
@@ -477,7 +477,7 @@ public class DBQuery extends DBRowSet
                 } 
                 else
                 {	// other constraints are not supported
-                    return error(Errors.NotSupported, "updateRecord");
+                    throw new EmpireException(Errors.NotSupported, "updateRecord");
                 }
             }
             // Add Restrictions
@@ -524,15 +524,15 @@ public class DBQuery extends DBRowSet
             {   // Error
                 if (affected == 0)
                 { // Record not found
-                    error(DBErrors.RecordUpdateFailed, table.getName());
+                    throw new EmpireException(DBErrors.RecordUpdateFailed, table.getName());
                 }
                 // Rollback
                 db.rollback(conn);
-                return false;
+                return;
             } 
             else if (affected > 1)
             { // More than one record
-                error(DBErrors.RecordUpdateInvalid, table.getName());
+                throw new EmpireException(DBErrors.RecordUpdateInvalid, table.getName());
             } 
             else
             { // success
@@ -546,7 +546,6 @@ public class DBQuery extends DBRowSet
         }
         // success
         rec.changeState(DBRecord.REC_VALID, keys);
-        return success();
     }
 
     /**
@@ -584,9 +583,9 @@ public class DBQuery extends DBRowSet
      * @return true if the record has been successfully deleted or false otherwise
      */
     @Override
-    public boolean deleteRecord(Object[] keys, Connection conn)
+    public void deleteRecord(Object[] keys, Connection conn)
     {
-        return error(Errors.NotImplemented, "deleteRecord");
+        throw new EmpireException(Errors.NotImplemented, "deleteRecord");
     }
 
 }
\ No newline at end of file

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBReader.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBReader.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBReader.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBReader.java Tue Jul 19 16:53:34 2011
@@ -18,17 +18,6 @@
  */
 package org.apache.empire.db;
 
-import org.apache.commons.beanutils.ConstructorUtils;
-import org.apache.empire.commons.Errors;
-import org.apache.empire.commons.ObjectUtils;
-import org.apache.empire.data.ColumnExpr;
-import org.apache.empire.data.DataType;
-import org.apache.empire.xml.XMLUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
 import java.io.IOException;
 import java.io.NotSerializableException;
 import java.io.ObjectOutputStream;
@@ -43,6 +32,18 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
+import org.apache.commons.beanutils.ConstructorUtils;
+import org.apache.empire.EmpireException;
+import org.apache.empire.commons.Errors;
+import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.data.ColumnExpr;
+import org.apache.empire.data.DataType;
+import org.apache.empire.xml.XMLUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
 
 /**
  * <P>
@@ -50,7 +51,7 @@ import java.util.Map;
  * In oder to perform a query call the open() function or - for single row queries - call getRecordData();<BR>
  * You can iterate through the rows using moveNext() or an iterator.<BR>
  * <P>
- * However take care: A reader must always be explcitly closed using the close() method!<BR>
+ * However take care: A reader must always be explicitly closed using the close() method!<BR>
  * Otherwise you may lock the JDBC connection and run out of resources.<BR>
  * Use <PRE>try { ... } finally { reader.close(); } </PRE> to make sure the reader is closed.<BR>
  * <P>
@@ -119,9 +120,7 @@ public class DBReader extends DBRecordDa
         public boolean hasNext()
         {
             try
-            { // clear previous error
-                clearError();
-                // Check position
+            {   // Check position
                 if (curCount >= maxCount)
                     return false;
                 // Check Recordset
@@ -129,9 +128,8 @@ public class DBReader extends DBRecordDa
                     return false;
                 // there are more records
                 return true;
-            } catch (SQLException e)
-            {
-                return error(e);
+            } catch (SQLException e) {
+                throw SQL2EmpireException(e);
             }
         }
 
@@ -187,7 +185,7 @@ public class DBReader extends DBRecordDa
             if (curCount >= maxCount)
                 return false;
             if (rset == null)
-                return error(Errors.ObjectNotValid, getClass().getName());
+                throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
             // Check next Record
             if (getCurrent == true)
             {
@@ -346,7 +344,6 @@ public class DBReader extends DBRecordDa
         }
         try
         { // Check Value on Resultset
-            clearError();
             rset.getObject(index + 1);
             return rset.wasNull();
         } catch (Exception e)
@@ -365,21 +362,17 @@ public class DBReader extends DBRecordDa
     @Override
     public Object getValue(int index)
     {
+        // Check params
         if (index < 0 || index >= colList.length)
-        { // Index out of range
-            error(Errors.OutOfRange, index);
-            return null;
-        }
+            throw new EmpireException(Errors.OutOfRange, index);
         try
-        { // Get Value from Resultset
-            clearError();
+        {   // Get Value from Resultset
             DataType dataType = colList[index].getDataType();
             return db.driver.getResultValue(rset, index + 1, dataType);
 
-        } catch (Exception e)
+        } catch (SQLException e)
         { // Operation failed
-            error(e);
-            return null;
+            throw SQL2EmpireException(e);
         }
     }
 
@@ -407,7 +400,7 @@ public class DBReader extends DBRecordDa
      * @param conn a valid JDBC connection.
      * @return true if successful
      */
-    public boolean open(DBCommandExpr cmd, boolean scrollable, Connection conn)
+    public void open(DBCommandExpr cmd, boolean scrollable, Connection conn)
     {
         if (isOpen())
             close();
@@ -417,11 +410,10 @@ public class DBReader extends DBRecordDa
         db = cmd.getDatabase();
         rset = db.executeQuery(sqlCmd, cmd.getParamValues(), scrollable, conn);
         if (rset==null)
-            return error(db);
+            throw new EmpireException(DBErrors.QueryNoResult, sqlCmd);
         // successfully opened
         colList = cmd.getSelectExprList();
         addOpenResultSet();
-        return success();
     }
 
     /**
@@ -433,9 +425,9 @@ public class DBReader extends DBRecordDa
      * @param conn a valid JDBC connection.
      * @return true if successful
      */
-    public boolean open(DBCommandExpr cmd, Connection conn)
+    public final void open(DBCommandExpr cmd, Connection conn)
     {
-        return open(cmd, false, conn);
+        open(cmd, false, conn);
     }
 
     /**
@@ -452,16 +444,14 @@ public class DBReader extends DBRecordDa
      * @param conn a valid JDBC connection.
      * @return true if successful
      */
-    public boolean getRecordData(DBCommandExpr cmd, Connection conn)
+    public void getRecordData(DBCommandExpr cmd, Connection conn)
     { // Open the record
-        if (!open(cmd, conn))
-            return false;
+        open(cmd, conn);
         // Get First Record
         if (!moveNext())
         { // Close
-            return error(DBErrors.QueryNoResult, cmd.getSelect());
+            throw new EmpireException(DBErrors.QueryNoResult, cmd.getSelect());
         }
-        return success();
     }
 
     /**
@@ -504,17 +494,15 @@ public class DBReader extends DBRecordDa
     public boolean skipRows(int count)
     {
         try
-        { // clear previous error
-            clearError();
-            // Check Recordset
+        {   // Check Recordset
             if (rset == null)
-                return error(Errors.ObjectNotValid, getClass().getName());
+                throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
             // Forward only cursor?
             int type = rset.getType();
             if (type == ResultSet.TYPE_FORWARD_ONLY)
             {
                 if (count < 0)
-                    return error(Errors.InvalidArg, count, "count");
+                    throw new EmpireException(Errors.InvalidArg, count, "count");
                 // Move
                 for (; count > 0; count--)
                 {
@@ -542,9 +530,9 @@ public class DBReader extends DBRecordDa
             }
             return true;
 
-        } catch (SQLException e)
-        { // an error ocurred
-            return error(e);
+        } catch (SQLException e) {
+            // an error occurred
+            throw new EmpireException(e);
         }
     }
 
@@ -556,23 +544,20 @@ public class DBReader extends DBRecordDa
     public boolean moveNext()
     {
         try
-        { // clear previous error
-            clearError();
-            // Check Recordset
+        {   // Check Recordset
             if (rset == null)
-                return error(Errors.ObjectNotValid, getClass().getName());
+                throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
             // Move Next
             if (rset.next() == false)
             { // Close recordset automatically after last record
                 close();
-                clearError();
                 return false;
             }
             return true;
 
-        } catch (SQLException e)
-        { // an error ocurred
-            return error(e);
+        } catch (SQLException e) {
+            // an error occurred
+            throw SQL2EmpireException(e);
         }
     }
 
@@ -582,8 +567,8 @@ public class DBReader extends DBRecordDa
      * Returns an row iterator for this reader.<BR>
      * There can only be one iterator at a time.
      * <P>
-     * @param maxCount the maximum number of item that shold be returned by this iterator
-     * @return the row interator
+     * @param maxCount the maximum number of item that should be returned by this iterator
+     * @return the row iterator
      */
     public Iterator<DBRecordData> iterator(int maxCount)
     {
@@ -602,7 +587,7 @@ public class DBReader extends DBRecordDa
      * Returns an row iterator for this reader.
      * There can only be one iterator at a time.
      * </PRE>
-     * @return the row interator
+     * @return the row iterator
      */
     public final Iterator<DBRecordData> iterator()
     {
@@ -618,15 +603,14 @@ public class DBReader extends DBRecordDa
      * </PRE>
      * @param rowset the rowset to which to attach
      * @param rec the record which to initialize
-     * @return true if the record has been initialized sucessfully or false otherwise
+     * @return true if the record has been initialized successfully or false otherwise
      */
-    public boolean initRecord(DBRowSet rowset, DBRecord rec)
+    public void initRecord(DBRowSet rowset, DBRecord rec)
     {
     	if (rowset==null)
-    		return error(Errors.InvalidArg, rowset, "rowset");
-    	if (rowset.initRecord(rec, this)==false)
-    		return error(rowset);
-    	return success();
+    	    throw new EmpireException(Errors.InvalidArg, rowset, "rowset");
+    	// init Record
+    	rowset.initRecord(rec, this);
     }
 
     /**
@@ -645,8 +629,7 @@ public class DBReader extends DBRecordDa
         // Check Recordset
         if (rset == null)
         {   // Resultset not available
-            error(Errors.ObjectNotValid, getClass().getName());
-            return null;
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         }
         // Query List
         try
@@ -672,8 +655,7 @@ public class DBReader extends DBRecordDa
                 else
                 {   // Use Property Setters
                     T bean = t.newInstance();
-                    if (getBeanProperties(bean)==false)
-                        return null;
+                    getBeanProperties(bean);
                     c.add(bean);
                 }
                 // Decrease count
@@ -682,18 +664,12 @@ public class DBReader extends DBRecordDa
             }
             // done
             return c;
-        } catch (InvocationTargetException e)
-        {
-            error(e);
-            return null;
-        } catch (IllegalAccessException e)
-        {
-            error(e);
-            return null;
-        } catch (InstantiationException e)
-        {
-            error(e);
-            return null;
+        } catch (InvocationTargetException e) {
+            throw new EmpireException(e);
+        } catch (IllegalAccessException e) {
+            throw new EmpireException(e);
+        } catch (InstantiationException e) {
+            throw new EmpireException(e);
         }
     }
     
@@ -726,14 +702,15 @@ public class DBReader extends DBRecordDa
      * @return true if successful
      */
     @Override
-    public boolean addColumnDesc(Element parent)
+    public int addColumnDesc(Element parent)
     {
         if (colList == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Add Field Description
         for (int i = 0; i < colList.length; i++)
             colList[i].addXml(parent, 0);
-        return success();
+        // return count
+        return colList.length; 
     }
 
     /**
@@ -743,10 +720,10 @@ public class DBReader extends DBRecordDa
      * @return true if successful
      */
     @Override
-    public boolean addRowValues(Element parent)
+    public int addRowValues(Element parent)
     {
         if (rset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Add all children
         for (int i = 0; i < colList.length; i++)
         { // Read all
@@ -764,7 +741,8 @@ public class DBReader extends DBRecordDa
                     elem.setAttribute("null", "yes"); // Null-Value
             }
         }
-        return success();
+        // return count
+        return colList.length; 
     }
 
     /**
@@ -798,7 +776,7 @@ public class DBReader extends DBRecordDa
     }
 
     /**
-     * Returns a XML document with the field descriptiona an values of this record.
+     * Returns a XML document with the field description an values of this record.
      * 
      * @return the new XML Document object
      */
@@ -811,8 +789,7 @@ public class DBReader extends DBRecordDa
         String rowsetElementName = getXmlDictionary().getRowSetElementName();
         Element root = XMLUtil.createDocument(rowsetElementName);
         // Add Field Description
-        if (!addColumnDesc(root))
-            return null;
+        addColumnDesc(root);
         // Add row rset
         addRows(root);
         // return Document

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecord.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecord.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecord.java Tue Jul 19 16:53:34 2011
@@ -18,8 +18,14 @@
  */
 package org.apache.empire.db;
 
+import java.lang.reflect.InvocationTargetException;
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.List;
+
 import org.apache.commons.beanutils.BeanUtilsBean;
 import org.apache.commons.beanutils.PropertyUtilsBean;
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.Options;
@@ -32,11 +38,6 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import java.lang.reflect.InvocationTargetException;
-import java.sql.Connection;
-import java.util.Collection;
-import java.util.List;
-
 
 /**
  * 
@@ -69,7 +70,7 @@ public class DBRecord extends DBRecordDa
 
     /**
      * Create a new DBRecord object.<BR>
-     * The record is not attachted to a RowSet and the record's state is intitially set to REC_INVALID.
+     * The record is not attached to a RowSet and the record's state is initially set to REC_INVALID.
      * 
      * Please derive your own Objects from this class.   
      */
@@ -321,11 +322,10 @@ public class DBRecord extends DBRecordDa
     public boolean wasModified(int index)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         if (index < 0 || index >= fields.length)
-            return error(Errors.OutOfRange, index);
+            throw new EmpireException(Errors.OutOfRange, index);
         // Check modified
-        clearError();
         if (modified == null)
             return false;
         return modified[index];
@@ -406,17 +406,10 @@ public class DBRecord extends DBRecordDa
     public Object getValue(int index)
     {   // Check state
         if (fields == null)
-        {   // Record not valid
-            error(Errors.ObjectNotValid, getClass().getName());
-            return null; 
-        }
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Check index
         if (index < 0 || index>= fields.length)
-        {   // Index out of range
-            error(Errors.OutOfRange, index);
-            return null; 
-        }
-        clearError();
+            throw new EmpireException(Errors.OutOfRange, index);
         // Special check for NO_VALUE 
         if (fields[index] == ObjectUtils.NO_VALUE)
             return null;
@@ -426,7 +419,7 @@ public class DBRecord extends DBRecordDa
     
     /**
      * Returns whether a field value is provided i.e. the value is not DBRowSet.NO_VALUE<BR>
-     * This function is only useful in cases where records are partically loaded.<BR>
+     * This function is only useful in cases where records are partially loaded.<BR>
      * 
      * @param index the filed index
      *  
@@ -435,13 +428,12 @@ public class DBRecord extends DBRecordDa
     public boolean isValueValid(int index)
     {   // Check state
         if (fields == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Check index
         if (index < 0 || index>= fields.length)
         {   // Index out of range
-            return error(Errors.OutOfRange, index);
+            throw new EmpireException(Errors.OutOfRange, index);
         }
-        clearError();
         // Special check for NO_VALUE
         return (fields[index] != ObjectUtils.NO_VALUE);
     }
@@ -505,32 +497,28 @@ public class DBRecord extends DBRecordDa
      * @param value the value
      * @return true if successful
      */
-    public boolean setValue(int i, Object value)
+    public void setValue(int i, Object value)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         if (i < 0 || i >= fields.length)
-            return error(Errors.OutOfRange, i);
+            throw new EmpireException(Errors.OutOfRange, i);
         // Strings special
         if ((value instanceof String) && ((String)value).length()==0)
             value = null;
         // Has Value changed?
         if (ObjectUtils.compareEqual(fields[i], value))
-            return success(); // no change
+            return; // no change
         // Field has changed
         DBColumn column = rowset.getColumn(i);
         if (column.isAutoGenerated())
         {   // Read Only column may be set
-            return error(DBErrors.FieldIsReadOnly, column.getName());
+            throw new EmpireException(DBErrors.FieldIsReadOnly, column.getName());
         }
         // Is Value valid
-        if (column.checkValue(value) == false)
-        { // Invalid Value for column
-            return error(column);
-        }
+        column.checkValue(value);
         // Init original values
         modifyValue(i, value);
-        return success();
     }
 
     /**
@@ -542,12 +530,12 @@ public class DBRecord extends DBRecordDa
      * @param value the value
      * @return true if successful
      */
-    public final boolean setValue(Column column, Object value)
+    public final void setValue(Column column, Object value)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Get Column Index
-        return setValue(rowset.getColumnIndex(column), value);
+        setValue(rowset.getColumnIndex(column), value);
     }
     
     /**
@@ -560,9 +548,7 @@ public class DBRecord extends DBRecordDa
     public boolean isFieldReadOnly(DBColumn column)
     {
         if (rowset==null)
-        {   error(Errors.ObjectNotValid, getClass().getName());
-            return true;
-        }
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Ask RowSet
         return (rowset.isColumnReadOnly(column));
     }
@@ -585,7 +571,7 @@ public class DBRecord extends DBRecordDa
     public boolean isFieldVisible(DBColumn column)
     {
         if (rowset==null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Check if field is present and the value is valid 
         int index = rowset.getColumnIndex(column);
         return (index>=0 && isValueValid(index));
@@ -609,36 +595,11 @@ public class DBRecord extends DBRecordDa
      * @param insert if true change the state of this object to REC_NEW
      * @return true if successful or false otherwise
      */
-    public boolean init(DBRowSet table, Object[] keyValues, boolean insert)
+    public void init(DBRowSet table, Object[] keyValues, boolean insert)
     { // Init with keys
-        if (table.initRecord(this, keyValues) == false)
-            return error(table);
+        table.initRecord(this, keyValues);
         if (insert)
             state = DBRecord.REC_NEW;
-        return success();
-    }
-
-    /**
-     * @param table 
-     * @param conn 
-     * @return true on succes
-     * @deprecated use {@link DBRecord#create(DBRowSet, Connection)}
-     */
-    @Deprecated
-	public final boolean initNew(DBRowSet table, Connection conn)
-    {
-        return (table.createRecord(this, conn) == false) ? error(table) : success();
-    }
-
-    /**
-     * @param table 
-     * @return true on succes
-     * @deprecated use {@link DBRecord#create(DBRowSet)}
-     */
-    @Deprecated
-	public final boolean initNew(DBRowSet table)
-    {
-        return initNew(table, null);
     }
     
     /**
@@ -653,9 +614,9 @@ public class DBRecord extends DBRecordDa
      * @param conn a valid JDBC connection
      * @return true if successful
      */
-    public boolean create(DBRowSet table, Connection conn)
+    public void create(DBRowSet table, Connection conn)
     {
-        return (table.createRecord(this, conn) == false) ? error(table) : success();
+        table.createRecord(this, conn);
     }
     
     /**
@@ -666,44 +627,44 @@ public class DBRecord extends DBRecordDa
      * @param table the table for which to create a record
      * @return true if successful
      */
-    public boolean create(DBRowSet table)
+    public void create(DBRowSet table)
     {
-        return create(table, null);
+        create(table, null);
     }
 
     /**
      * Loads a record from the database identified by it's primary key. 
-     * After sucessful reading the record will be valid and all values will be accessible.
+     * After successful reading the record will be valid and all values will be accessible.
      * @see org.apache.empire.db.DBTable#readRecord(DBRecord, Object[], Connection)
      * 
      * @param table the rowset from which to read the record
      * @param keys an array of the primary key values
      * @param conn a valid connection to the database.
-     * @return true if the record was sucessfully loaded or false if the record was not found or an error occurred.
+     * @return true if the record was successfully loaded or false if the record was not found or an error occurred.
      */
-    public boolean read(DBRowSet table, Object[] keys, Connection conn)
+    public void read(DBRowSet table, Object[] keys, Connection conn)
     {
-        return (table.readRecord(this, keys, conn) == false) ? error(table) : success();
+        table.readRecord(this, keys, conn);
     }
 
     /**
      * Loads a record from the database identified by it's primary key. 
-     * After sucessful reading the record will be valid and all values will be accessible.
+     * After successful reading the record will be valid and all values will be accessible.
      * @see org.apache.empire.db.DBTable#readRecord(DBRecord, Object[], Connection)
      * 
      * @param table the rowset from which to read the record
      * @param id the primary key of the record to load.
      * @param conn a valid connection to the database.
-     * @return true if the record was sucessfully loaded or false if the record was not found or an error occurred.
+     * @return true if the record was successfully loaded or false if the record was not found or an error occurred.
      */
-    public final boolean read(DBRowSet table, Object id, Connection conn)
+    public final void read(DBRowSet table, Object id, Connection conn)
     {
         if (id instanceof Collection<?>)
         {   // If it's a collection then convert it to an array
-            return read(table, ((Collection<?>)id).toArray(), conn);
+            read(table, ((Collection<?>)id).toArray(), conn);
         }
         // Simple One-Column key
-        return read(table, new Object[] { id }, conn);
+        read(table, new Object[] { id }, conn);
     }
 
     /**
@@ -713,13 +674,12 @@ public class DBRecord extends DBRecordDa
      * @param conn a valid connection to the database.
      * @return true if successful
      */
-    public boolean update(Connection conn)
+    public void update(Connection conn)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
-        if (!rowset.updateRecord(this, conn))
-            return error(rowset);
-        return success();
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
+        // update
+        rowset.updateRecord(this, conn);
     }
 
     /**
@@ -733,19 +693,17 @@ public class DBRecord extends DBRecordDa
      * @param conn a valid connection to the database.
      * @return true if successful
      */
-    public boolean delete(Connection conn)
+    public void delete(Connection conn)
     {
         if (isValid()==false)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Delete only if record is not new
         if (!isNew())
         {
             Object[] keys = rowset.getRecordKey(this);
-            if (rowset.deleteRecord(keys, conn)==false)
-                return error(rowset);
+            rowset.deleteRecord(keys, conn);
         }
         close();
-        return success();
     }
 
     /**
@@ -754,11 +712,12 @@ public class DBRecord extends DBRecordDa
      * @return true if successful
      */
     @Override
-    public boolean addColumnDesc(Element parent)
+    public int addColumnDesc(Element parent)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Add Field Description
+        int count = 0;
         List<DBColumn> columns = rowset.getColumns();
         for (int i = 0; i < columns.size(); i++)
         { // Add Field
@@ -766,8 +725,9 @@ public class DBRecord extends DBRecordDa
             if (isFieldVisible(column)==false)
                 continue;
             column.addXml(parent, 0);
+            count++;
         }
-        return success();
+        return count;
     }
 
     /**
@@ -777,10 +737,10 @@ public class DBRecord extends DBRecordDa
      * @return true if successful
      */
     @Override
-    public boolean addRowValues(Element parent)
+    public int addRowValues(Element parent)
     {
         if (rowset == null)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // set row key
         DBColumn[] keyColumns = rowset.getKeyColumns();
         if (keyColumns != null && keyColumns.length > 0)
@@ -803,6 +763,7 @@ public class DBRecord extends DBRecordDa
         if (isNew())
             parent.setAttribute("new", "1");
         // Add all children
+        int count = 0;
         List<DBColumn> columns = rowset.getColumns();
         for (int i = 0; i < fields.length; i++)
         { // Read all
@@ -815,8 +776,10 @@ public class DBRecord extends DBRecordDa
                 XMLUtil.addElement(parent, name, getString(i));
             else
                 XMLUtil.addElement(parent, name).setAttribute("null", "yes"); // Null-Value
+            // increase count
+            count++;
         }
-        return success();
+        return count;
     }
     
     /**
@@ -829,7 +792,7 @@ public class DBRecord extends DBRecordDa
     }
 
     /**
-     * Returns a XML document with the field descriptiona an values of this record.
+     * Returns a XML document with the field description an values of this record.
      * 
      * @return the new XML Document object
      */
@@ -837,22 +800,18 @@ public class DBRecord extends DBRecordDa
     public Document getXmlDocument()
     {
         if (rowset == null)
-        {   error(Errors.ObjectNotValid, getClass().getName());
-            return null;
-        }
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Create Document
         DBXmlDictionary xmlDic = getXmlDictionary();
         Element root = XMLUtil.createDocument(xmlDic.getRowSetElementName());
         if (rowset.getName() != null)
             root.setAttribute("name", rowset.getName());
         // Add Field Description
-        if (!addColumnDesc(root))
-            return null;
+        if (addColumnDesc(root)==0)
+            throw new EmpireException(Errors.NoResult, rowset.getName());
         // Add row Values
-        if (!addRowValues(XMLUtil.addElement(root, xmlDic.getRowElementName())))
-            return null;
+        addRowValues(XMLUtil.addElement(root, xmlDic.getRowElementName()));
         // return Document
-        clearError();
         return root.getOwnerDocument();
     }
 
@@ -893,9 +852,9 @@ public class DBRecord extends DBRecordDa
      * @param bean the Java Bean from which to read the value from
      * @param property the name of the property
      * @param column the column for which to set the record value
-     * @return true if the value has been sucessfully set or false if not    
+     * @return true if the value has been successfully set or false if not    
      */
-    protected boolean setBeanValue(Object bean, String property, Column column)
+    protected void setBeanValue(Object bean, String property, Column column)
     {
         try
         {   /*
@@ -908,27 +867,26 @@ public class DBRecord extends DBRecordDa
             Object value = pub.getSimpleProperty(bean, property);
 
             // Now, set the record value
-            return setValue( column, value ); 
+            setValue( column, value ); 
 
         } catch (IllegalAccessException e)
         {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         } catch (InvocationTargetException e)
         {   log.error(bean.getClass().getName() + ": unable to get property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         } catch (NoSuchMethodException e)
-        { 
-            log.warn(bean.getClass().getName() + ": no getter available for property '" + property + "'");
-            return error(e);
+        {   log.warn(bean.getClass().getName() + ": no getter available for property '" + property + "'");
+            throw new EmpireException(e);
         }
     }
     
     /**
-     * Sets record values from the suppied java bean.
+     * Sets record values from the supplied java bean.
      * 
-     * @return true if at least one value has been set sucessfully 
+     * @return true if at least one value has been set successfully 
      */
-    public boolean setBeanValues(Object bean, Collection<Column> ignoreList)
+    public int setBeanValues(Object bean, Collection<Column> ignoreList)
     {
         // Add all Columns
         int count = 0;
@@ -941,17 +899,17 @@ public class DBRecord extends DBRecordDa
                 continue; // ignore this property
             // Get Property Name
             String property = column.getBeanPropertyName();
-            if (setBeanValue(bean, property, column))
-                count++;
+            setBeanValue(bean, property, column);
+            count++;
         }
-        return (count > 0);
+        return count;
     }
 
     /**
      * Sets record values from the suppied java bean.
      * @return true if at least one value has been set sucessfully
      */
-    public final boolean setBeanValues(Object bean)
+    public final int setBeanValues(Object bean)
     {
         return setBeanValues(bean, null);
     }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java Tue Jul 19 16:53:34 2011
@@ -18,7 +18,12 @@
  */
 package org.apache.empire.db;
 // XML
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Date;
+
 import org.apache.commons.beanutils.BeanUtils;
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.DateUtils;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
@@ -29,10 +34,6 @@ import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Date;
-
 
 /**
  * This interface defines for the classes DDRecordSet and DBRecord.
@@ -55,8 +56,8 @@ public abstract class DBRecordData exten
     // Column lookup
     public abstract ColumnExpr getColumnExpr(int i);
     // xml
-    public abstract boolean  addColumnDesc(Element parent);
-    public abstract boolean  addRowValues (Element parent);
+    public abstract int     addColumnDesc(Element parent);
+    public abstract int     addRowValues (Element parent);
     public abstract Document getXmlDocument();
     // others
     public abstract void    close();
@@ -95,7 +96,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to integer if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final int getInt(ColumnExpr column)
@@ -121,7 +122,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to a long if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final long getLong(ColumnExpr column)
@@ -147,7 +148,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to double if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final double getDouble(ColumnExpr column)
@@ -173,7 +174,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to boolean if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final boolean getBoolean(ColumnExpr column)
@@ -197,7 +198,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to a string if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final String getString(ColumnExpr column)
@@ -223,7 +224,7 @@ public abstract class DBRecordData exten
      * Returns a data value for the desired column.
      * The data value is converted to a Date if necessary.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return the value
      */
     public final Date getDateTime(ColumnExpr column)
@@ -245,7 +246,7 @@ public abstract class DBRecordData exten
     /**
      * Checks whether or not the value for the given column is null.
      * 
-     * @param column identifing the column
+     * @param column identifying the column
      * @return true if the value is null or false otherwise
      */
     public final boolean isNull(ColumnExpr column)
@@ -256,7 +257,7 @@ public abstract class DBRecordData exten
     /**
      * Set a single property value of a java bean object used by readProperties.
      */
-    protected boolean getBeanProperty(Object bean, String property, Object value)
+    protected void getBeanProperty(Object bean, String property, Object value)
     {
         try
         {   /*
@@ -264,7 +265,7 @@ public abstract class DBRecordData exten
                 log.trace(bean.getClass().getName() + ": setting property '" + property + "' to " + String.valueOf(value));
             */    
             if (value instanceof Date)
-            {   // Patch for Strage Date Bug in BeanUtils
+            {   // Patch for Stage Date Bug in BeanUtils
                 value = DateUtils.addDate((Date)value, 0, 0, 0);
             }
             // Set Property Value
@@ -279,16 +280,15 @@ public abstract class DBRecordData exten
              * res); }
              */
             // done
-            return success();
 
         } catch (IllegalAccessException e)
         {
             log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
         } catch (InvocationTargetException e)
         {
             log.error(bean.getClass().getName() + ": unable to set property '" + property + "'");
-            return error(e);
+            throw new EmpireException(e);
             /*
              * } catch(NoSuchMethodException e) { log.warn(bean.getClass().getName() + ": cannot check value of property '" +
              * property + "'"); return true;
@@ -301,9 +301,10 @@ public abstract class DBRecordData exten
      * 
      * @return true if successful
      */
-    public boolean getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList)
+    public int getBeanProperties(Object bean, Collection<ColumnExpr> ignoreList)
     {
         // Add all Columns
+        int count = 0;
         for (int i = 0; i < getFieldCount(); i++)
         { // Check Property
             ColumnExpr column = getColumnExpr(i);
@@ -311,13 +312,10 @@ public abstract class DBRecordData exten
                 continue; // ignore this property
             // Get Property Name
             String property = column.getBeanPropertyName();
-            if (getBeanProperty(bean, property, this.getValue(i))==false)
-            {   // Error setting property.
-                return false;
-            }
+            getBeanProperty(bean, property, this.getValue(i));
+            count++;
         }
-        // Success, All Properties have been set
-        return success();
+        return count;
     }
 
     /**
@@ -325,7 +323,7 @@ public abstract class DBRecordData exten
      * 
      * @return true if successful
      */
-    public final boolean getBeanProperties(Object bean)
+    public final int getBeanProperties(Object bean)
     {
         return getBeanProperties(bean, null);
     }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java Tue Jul 19 16:53:34 2011
@@ -18,6 +18,15 @@
  */
 package org.apache.empire.db;
 
+import java.sql.Connection;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
@@ -28,14 +37,6 @@ import org.apache.empire.db.expr.column.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.Connection;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 
 /**
  * This class is the base class for all the DBTable,
@@ -95,9 +96,9 @@ public abstract class DBRowSet extends D
     
     public abstract String getAlias();
 
-    public abstract boolean createRecord(DBRecord rec, Connection conn);
+    public abstract void createRecord(DBRecord rec, Connection conn);
 
-    public abstract boolean deleteRecord(Object[] keys, Connection conn);
+    public abstract void deleteRecord(Object[] keys, Connection conn);
     
     /**
      * Returns the full qualified name of the rowset.
@@ -283,21 +284,20 @@ public abstract class DBRowSet extends D
     }
     
     /**
-     * Adds a column reference to the ist of table references.
-     * This method ist internally called from DBDatabase.addReleation().
+     * Adds a column reference to the list of table references.
+     * This method is internally called from DBDatabase.addReleation().
      * 
      * @param source a column reference for one of this table's column
      * @param target the target column to which the source column references
      */
-    protected boolean addColumnReference(DBColumn source, DBColumn target)
+    protected void addColumnReference(DBColumn source, DBColumn target)
     {
         if (source.getRowSet()!=this)
-            return error(Errors.InvalidArg, source.getFullName(), "column");
+            throw new EmpireException(Errors.InvalidArg, source.getFullName(), "column");
         if (columnReferences== null)
             columnReferences = new HashMap<DBColumn, DBColumn>();
         // Check if column is already there
         columnReferences.put(source, target);
-        return success();
     }
     
     /**
@@ -350,19 +350,18 @@ public abstract class DBRowSet extends D
     }
 
     /**
-     * Initialise this DBRowSet object and sets it's initial state.
+     * Initialize this DBRowSet object and sets it's initial state.
      * 
-     * @param rec the DBRecord object to initialise this DBRowSet object
+     * @param rec the DBRecord object to initialize this DBRowSet object
      * @param state the state of this DBRowSet object
      * @return true if successful
      */
-    protected boolean prepareInitRecord(DBRecord rec, int state, Object rowSetData)
+    protected void prepareInitRecord(DBRecord rec, int state, Object rowSetData)
     {
         if (columns.size() < 1)
-            return error(Errors.ObjectNotValid, getClass().getName());
+            throw new EmpireException(Errors.ObjectNotValid, getClass().getName());
         // Init
         rec.init(this, state, rowSetData);
-        return success();
     }
 
     /**
@@ -373,11 +372,10 @@ public abstract class DBRowSet extends D
      * @param keyValues an array of the primary key columns
      * @return true if successful
      */
-    public boolean initRecord(DBRecord rec, Object[] keyValues)
+    public void initRecord(DBRecord rec, Object[] keyValues)
     {
-        // Inititialisierung
-        if (!prepareInitRecord(rec, DBRecord.REC_EMTPY, null))
-            return false;
+        // Prepare
+        prepareInitRecord(rec, DBRecord.REC_EMTPY, null);
         // Initialize all Fields
         Object[] fields = rec.getFields();
         for (int i = 0; i < fields.length; i++)
@@ -394,7 +392,7 @@ public abstract class DBRowSet extends D
             }
         }
         // Init
-        return completeInitRecord(rec);
+        completeInitRecord(rec);
     }
 
     /**
@@ -408,7 +406,7 @@ public abstract class DBRowSet extends D
      * @param recData the record data from which to initialized the record
      * @return true if successful
      */
-    public boolean initRecord(DBRecord rec, DBRecordData recData)
+    public void initRecord(DBRecord rec, DBRecordData recData)
     {
         // Initialize the record
         prepareInitRecord(rec, DBRecord.REC_VALID, null);
@@ -424,7 +422,7 @@ public abstract class DBRowSet extends D
             	{	// Field not available in Record Data
             		if (primaryKey!=null && primaryKey.contains(column))
             		{	// Error: Primary Key not supplied
-            			return error(DBErrors.RecordInvalidKey, column.toString());
+            		    throw new EmpireException(DBErrors.RecordInvalidKey, column.toString());
             		}
                     if (timestampColumn == column)
                     { // Check the update Time Stamp
@@ -437,61 +435,28 @@ public abstract class DBRowSet extends D
             	else
             	{   // Get Field value
                     fields[i] = recData.getValue(rdi);
-                    // Check for error
-                    if (fields[i]==null && recData.hasError())
-                        return error(recData);
             	}
             } catch (Exception e)
             {   // Unknown exception
                 log.error("initRecord exception: " + e.toString());
                 rec.close();
-                return error(e);
+                throw new EmpireException(e);
             }
         }
         // Done
-        return completeInitRecord(rec);
+        completeInitRecord(rec);
     }
     
     /**
-     * Reads a single record from the database using the given command object.<BR>
-     * If a reocord is found the DBRecord object will hold all record data. 
+     * Completes the record initialization.<BR>
+     * Override this function to do post initialization processing.
      * <P>
-     * @param rec the DBRecord object which holds the record data
-     * @param cmd the SQL-Command used to query the record
-     * @param conn a valid JDBC connection.
+     * @param rec the DBRecord object to initialize
      * @return true if successful
      */
-    protected boolean readRecord(DBRecord rec, DBCommand cmd, Connection conn)
-    {
-        DBReader reader = null;
-        try
-        {
-            clearError();
-            reader = new DBReader();
-            if (reader.getRecordData(cmd, conn)==false)
-                return error(reader);
-            if (initRecord(rec, reader)==false)
-            	return false;
-            // Done
-            return success();
-            
-        } finally
-        {
-        	reader.close();
-        }
-    }
-    
-    /**
-     * Completes the record initialisation.<BR>
-     * Override this function to do post initialisation processing.
-     * <P>
-     * @param rec the DBRecord object to initialise
-     * @return true if successful
-     */
-    protected boolean completeInitRecord(DBRecord rec)
+    protected void completeInitRecord(DBRecord rec)
     {
     	rec.onRecordChanged();
-        return success();
     }
     
     /**
@@ -500,15 +465,15 @@ public abstract class DBRowSet extends D
      * @param key the record key
      * @return true if the constraints have been successfully set or false otherwise
      */
-    protected boolean setKeyConstraints(DBCommand cmd, Object[] key)
+    protected void setKeyConstraints(DBCommand cmd, Object[] key)
     {
         // Check Primary key
         if (primaryKey == null ) 
-            return error(DBErrors.NoPrimaryKey, getName()); // Invalid Argument
+            throw new EmpireException(DBErrors.NoPrimaryKey, getName()); // Invalid Argument
         // Check Columns
         DBColumn[] keyColumns = primaryKey.getColumns();
         if (key == null || key.length != keyColumns.length)
-            return error(DBErrors.RecordInvalidKey, key); // Invalid Argument
+            throw new EmpireException(DBErrors.RecordInvalidKey, key); // Invalid Argument
         // Add the key constraints
         for (int i = 0; i < key.length; i++)
         {   // Set key column constraint
@@ -517,7 +482,29 @@ public abstract class DBRowSet extends D
                 value = cmd.addParam(keyColumns[i], value);
             cmd.where(keyColumns[i].is(value));
         }    
-        return true;
+    }
+    
+    /**
+     * Reads a single record from the database using the given command object.<BR>
+     * If a record is found the DBRecord object will hold all record data. 
+     * <P>
+     * @param rec the DBRecord object which holds the record data
+     * @param cmd the SQL-Command used to query the record
+     * @param conn a valid JDBC connection.
+     * @return true if successful
+     */
+    protected void readRecord(DBRecord rec, DBCommand cmd, Connection conn)
+    {
+        DBReader reader = null;
+        try
+        {   // read record using a DBReader
+            reader = new DBReader();
+            reader.getRecordData(cmd, conn);
+            initRecord(rec, reader);
+            
+        } finally {
+            reader.close();
+        }
     }
     
     /**
@@ -528,27 +515,28 @@ public abstract class DBRowSet extends D
      * @param conn a valid JDBC connection.
      * @return true if successful
      */
-    public boolean readRecord(DBRecord rec, Object[] key, Connection conn)
+    public void readRecord(DBRecord rec, Object[] key, Connection conn)
     {
         // Check Arguments
         if (conn == null || rec == null)
-            return error(Errors.InvalidArg, null, "conn|rec");
+            throw new EmpireException(Errors.InvalidArg, null, "conn|rec");
         // Select
         DBCommand cmd = db.createCommand();
         cmd.select(columns);
         // Set key constraints
-        if (!setKeyConstraints(cmd, key))
-        	return false;
-        // Read Record
-        if (!readRecord(rec, cmd, conn))
-        {   // Record not found
-            if (getErrorType()==DBErrors.QueryNoResult)
-                return error(DBErrors.RecordNotFound, key);
-            // Return given error
-            return false;
+        setKeyConstraints(cmd, key);
+        try {
+            // Read Record
+            readRecord(rec, cmd, conn);
+        } catch (EmpireException e) {
+            // Translate exception
+            if (e.getErrorType()==DBErrors.QueryNoResult)
+                // Record not found
+                throw new EmpireException(DBErrors.RecordNotFound, key);
+            else
+                // Other error
+                throw e;
         }
-        // Done
-        return success();
     }
 
     /**
@@ -562,13 +550,12 @@ public abstract class DBRowSet extends D
     {
         // Check Arguments
         if (conn == null)
-            return error(Errors.InvalidArg, conn, "conn");
+            throw new EmpireException(Errors.InvalidArg, conn, "conn");
         // Select
         DBCommand cmd = db.createCommand();
         cmd.select(count());
         // Set key constraints
-        if (!setKeyConstraints(cmd, key))
-        	return false;
+        setKeyConstraints(cmd, key);
         // check exits
         return (db.querySingleInt(cmd.getSelect(), conn)==1);
     }
@@ -597,13 +584,13 @@ public abstract class DBRowSet extends D
      * <P>
      * @param rec the DBRecord object. contains all fields and the field properties
      * @param conn a valid JDBC connection.
-     * @return true if the update was sucessful or false otherwise
+     * @return true if the update was successful or false otherwise
      */
-    public boolean updateRecord(DBRecord rec, Connection conn)
+    public void updateRecord(DBRecord rec, Connection conn)
     {
         // Check Arguments
         if (conn == null)
-            return error(Errors.InvalidArg, conn, "conn");
+            throw new EmpireException(Errors.InvalidArg, conn, "conn");
         // Get the new Timestamp
         String name = getName();
         Timestamp timestamp = (timestampColumn!=null) ? db.getUpdateTimestamp(conn) : null;
@@ -620,7 +607,7 @@ public abstract class DBRowSet extends D
                 if (primaryKey == null)
                 { // Requires a primary key
                     log.error("updateRecord: "  + name + " no primary key defined!");
-                    return error(DBErrors.NoPrimaryKey, name);
+                    throw new EmpireException(DBErrors.NoPrimaryKey, name);
                 }
                 for (int i = 0; i < columns.size(); i++)
                 { // search for the column
@@ -657,8 +644,7 @@ public abstract class DBRowSet extends D
                         if (col.isReadOnly())
                             log.warn("updateRecord: Read-only column '" + col.getName() + " has been modified!");
                         // Check the value
-                        if (!col.checkValue(value))
-                            return error(col);
+                        col.checkValue(value);
                         // Set the column
                         cmd.set(col.to(value));
                         setCount++;
@@ -694,19 +680,19 @@ public abstract class DBRowSet extends D
                     // Add the value to the command
                     if (empty==false)
                     {   // Check the value
-                        if (!col.isAutoGenerated() && !col.checkValue(value))
-                            return error(col);
+                        if (col.isAutoGenerated()==false)
+                            col.checkValue(value);
                         // Insert a field
                         cmd.set(col.to(value));
                         setCount++;
                     }
                     else if (primaryKey!=null && primaryKey.contains(col))
                     {   // All primary key fields must be supplied
-                        return error(DBErrors.FieldNotNull, col.getName());
+                        throw new EmpireException(DBErrors.FieldNotNull, col.getName());
                     }
                     else if (col.isRequired())
                     {   // Error Column is required!
-                        return error(DBErrors.FieldNotNull, col.getName());
+                        throw new EmpireException(DBErrors.FieldNotNull, col.getName());
                     }
                 }
                 sql = cmd.getInsert();
@@ -714,26 +700,26 @@ public abstract class DBRowSet extends D
 
             default:
                 log.warn("updateRecord: " + name + " record has not been modified! ");
-                return success();
+                return;
         }
         if (setCount == 0)
-        { // Cannot update or insert fields
+        {   // Nothing to update
             log.info("updateRecord: " + name + " nothing to update or insert!");
-            return success();
+            return;
         }
         // Perform action
         int affected = db.executeSQL(sql, cmd.getParamValues(), conn, setGenKey);
         if (affected < 0)
-        { // Update Failed
-            return error(db);
+        {   // Update Failed
+            throw new EmpireException(Errors.Internal, "Unexpected return value.");
         } 
         else if (affected == 0)
         { // Record not found
-            return error(DBErrors.RecordUpdateFailed, name);
+            throw new EmpireException(DBErrors.RecordUpdateFailed, name);
         } 
         else if (affected > 1)
         { // Multiple Records affected
-            return error(DBErrors.RecordUpdateInvalid, name);
+            throw new EmpireException(DBErrors.RecordUpdateInvalid, name);
         }
         // Correct Timestamp
         if (timestampColumn != null)
@@ -744,7 +730,6 @@ public abstract class DBRowSet extends D
         }
         // Change State
         rec.changeState(DBRecord.REC_VALID, null);
-        return success();
     }
     
     /**
@@ -754,9 +739,9 @@ public abstract class DBRowSet extends D
      * @param conn a valid JDBC connection
      * @return true if the record has been successfully deleted or false otherwise
      */
-    public final boolean deleteRecord(Object id, Connection conn)
+    public final void deleteRecord(Object id, Connection conn)
     {
-        return deleteRecord(new Object[] { id }, conn);
+        deleteRecord(new Object[] { id }, conn);
     }
 
     /**
@@ -766,13 +751,13 @@ public abstract class DBRowSet extends D
      * @param conn a valid connection
      * @return true if all reference records could be deleted
      */
-    protected final boolean deleteAllReferences(Object[] key, Connection conn)
+    protected final void deleteAllReferences(Object[] key, Connection conn)
     {
         // Merge Sub-Records
         List<DBRelation> relations = db.getRelations();
         DBColumn[] keyColumns = getKeyColumns();
         if (keyColumns==null)
-            return success(); // No primary key - no references!
+            return; // No primary key - no references!
         // Find all relations
         for (DBRelation rel : relations)
         {   // References
@@ -782,28 +767,25 @@ public abstract class DBRowSet extends D
                 if (refs[i].getTargetColumn().equals(keyColumns[0]))
                 {   // Found a reference on RowSet
                     DBRowSet rs = refs[0].getSourceColumn().getRowSet(); 
-                    if (rs.deleteReferenceRecords(refs, key, conn)==false)
-                        return false;
+                    rs.deleteReferenceRecords(refs, key, conn);
                 }
             }
         }
-        // No delete this record
-        return success();
     }
     
     /**
      * Deletes all records which are referenced by a particular relation.
      * <P>
-     * @param refs the reference columns belonging to the releation
+     * @param refs the reference columns belonging to the relation
      * @param parentKey the key of the parent element
      * @param conn a valid connection
      * @return true if all records could be deleted or false otherwise
      */
-    protected boolean deleteReferenceRecords(DBReference[] refs, Object[] parentKey, Connection conn)
+    protected void deleteReferenceRecords(DBReference[] refs, Object[] parentKey, Connection conn)
     {
         // Key length and reference length must match
         if (refs.length!=parentKey.length)
-            return error(DBErrors.RecordInvalidKey);
+            throw new EmpireException(DBErrors.RecordInvalidKey);
         // Rowset
         DBColumn[] keyColumns = getKeyColumns();
         if (keyColumns==null || keyColumns.length==0)
@@ -812,7 +794,7 @@ public abstract class DBRowSet extends D
             for (int i=0; i<parentKey.length; i++)
                 cmd.where(refs[i].getSourceColumn().is(parentKey[i]));
             if (db.executeSQL(cmd.getDelete((DBTable)this), conn)<0)
-                return error(db);
+                throw new EmpireException(Errors.Internal, "Unexpected return value.");
         }
         else
         {   // Query all keys
@@ -828,12 +810,10 @@ public abstract class DBRowSet extends D
             for (Object[] recKey : recKeys)
             {   
                 log.info("Deleting Record " + StringUtils.valueOf(recKey) + " from table " + getName());
-                if (deleteRecord(recKey, conn)==false)
-                    return false;
+                deleteRecord(recKey, conn);
             }
         }
         // Done
-        return success();
     }
     
 }

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBSQLScript.java Tue Jul 19 16:53:34 2011
@@ -23,6 +23,7 @@ import java.sql.SQLException;
 import java.util.ArrayList;
 import java.util.Iterator;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.ErrorObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -49,10 +50,9 @@ public class DBSQLScript extends ErrorOb
      * @param sql the statement
      * @return true if successful
      */
-    public boolean addStmt(String sql)
+    public void addStmt(String sql)
     {
         sqlCmdList.add(sql);
-        return success();
     }
     
     /**
@@ -61,17 +61,15 @@ public class DBSQLScript extends ErrorOb
      * @param sql the statement
      * @return true if successful
      */
-    public final boolean addStmt(StringBuilder sql)
+    public final void addStmt(StringBuilder sql)
     {
-        if (!addStmt(sql.toString()))
-            return false;
+        addStmt(sql.toString());
         // Clear Builder
         sql.setLength(0);
-        return true;
     }
     
     /**
-     * Returns the number of statemetns in this script
+     * Returns the number of statements in this script
      * @return number of statements in this script
      */
     public int getCount()
@@ -104,7 +102,7 @@ public class DBSQLScript extends ErrorOb
      * @param ignoreErrors true if errors should be ignored
      * @return true if the script has been run successful or false otherwise 
      */
-    public boolean run(DBDatabaseDriver driver, Connection conn, boolean ignoreErrors)
+    public void run(DBDatabaseDriver driver, Connection conn, boolean ignoreErrors)
     {
         log.debug("Running script containing " + String.valueOf(getCount()) + " statements.");
         for(String stmt : sqlCmdList)
@@ -117,13 +115,15 @@ public class DBSQLScript extends ErrorOb
                 // SQLException
                 log.error(e.toString(), e);
                 if (ignoreErrors==false)
-                    return error(DBErrors.SQLException, e);
+                {   // forward exception
+                    String msg = driver.extractErrorMessage(e);
+                    throw new EmpireException(DBErrors.SQLException, new Object[] { msg }, e);
+                }    
                 // continue
                 log.debug("Ignoring error. Continuing with script...");
             }
         }
         log.debug("Script completed.");
-        return success();
     }
     
     /**

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTable.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTable.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTable.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTable.java Tue Jul 19 16:53:34 2011
@@ -19,16 +19,17 @@
 package org.apache.empire.db;
 
 // java
-import org.apache.empire.commons.Errors;
-import org.apache.empire.data.DataMode;
-import org.apache.empire.data.DataType;
-
 import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.empire.EmpireException;
+import org.apache.empire.commons.Errors;
+import org.apache.empire.data.DataMode;
+import org.apache.empire.data.DataType;
+
 
 /**
  * This class represent one table of the database.
@@ -167,15 +168,14 @@ public class DBTable extends DBRowSet im
      * 
      * @param column a column object
      */
-    protected boolean addColumn(DBTableColumn column)
+    protected void addColumn(DBTableColumn column)
     { // find column by name
         if (column==null || column.getRowSet()!=this)
-            return error(Errors.InvalidArg, column, "column");
+            throw new EmpireException(Errors.InvalidArg, column, "column");
         if (columns.contains(column) == true)
-            return error(Errors.ItemExists, column.getName());
+            throw new EmpireException(Errors.ItemExists, column.getName());
         // add now
         columns.add(column);
-        return true;
     }
 
     /**
@@ -267,17 +267,16 @@ public class DBTable extends DBRowSet im
      * 
      * @return true on success
      */
-    public boolean setPrimaryKey(DBColumn[] columns)
+    public void setPrimaryKey(DBColumn[] columns)
     {
         if (columns==null || columns.length==0)
-            return error(Errors.InvalidArg, columns, "columns");
+            throw new EmpireException(Errors.InvalidArg, columns, "columns");
         // All columns must belong to this table
         for (int i=0; i<columns.length; i++)
             if (columns[i].getRowSet()!=this)
-                return error(Errors.InvalidArg, columns[i].getFullName(), "columns");
+                throw new EmpireException(Errors.InvalidArg, columns[i].getFullName(), "columns");
         // Set primary Key now
         primaryKey = new DBIndex(name + "_PK", DBIndex.PRIMARYKEY, columns);
-        return true;
     }
 
     /**
@@ -322,13 +321,12 @@ public class DBTable extends DBRowSet im
      * 
      * @return true on success
      */
-    public boolean addIndex(String indexName, boolean unique, DBColumn[] indexColumns)
+    public void addIndex(String indexName, boolean unique, DBColumn[] indexColumns)
     {
         if (indexName==null || indexColumns==null || indexColumns.length==0)
-            return error(Errors.InvalidArg, null, "name|columns");
+            throw new EmpireException(Errors.InvalidArg, null, "name|columns");
         // add Index now
         indexes.add(new DBIndex(indexName, (unique) ? DBIndex.UNIQUE : DBIndex.STANDARD, indexColumns));
-        return true;
     }
 
     /**
@@ -381,11 +379,10 @@ public class DBTable extends DBRowSet im
      * @return true if successful
      */
     @Override
-    public boolean createRecord(DBRecord rec, Connection conn)
+    public void createRecord(DBRecord rec, Connection conn)
     {
-        // Inititialisierung
-        if (!prepareInitRecord(rec, DBRecord.REC_NEW, null))
-            return false;
+        // Prepare
+        prepareInitRecord(rec, DBRecord.REC_NEW, null);
         // Set Defaults
         int count = columns.size();
         for (int i = 0; i < count; i++)
@@ -396,7 +393,7 @@ public class DBTable extends DBRowSet im
                 rec.modifyValue(i, value); 
         }
         // Init
-        return completeInitRecord(rec);
+        completeInitRecord(rec);
     }
 
     /**
@@ -429,44 +426,40 @@ public class DBTable extends DBRowSet im
      * @return true if successful
      */
     @Override
-    public boolean deleteRecord(Object[] key, Connection conn)
+    public void deleteRecord(Object[] key, Connection conn)
     {
         // Check Primary key
         if (primaryKey == null )
-            return error(DBErrors.NoPrimaryKey, getName());
+            throw new EmpireException(DBErrors.NoPrimaryKey, getName());
 
         // Check Columns
         DBColumn[] keyColumns = primaryKey.getColumns();
         if (key == null || key.length != keyColumns.length)
-            return error(Errors.InvalidArg, key); // Invalid Argument
+            throw new EmpireException(Errors.InvalidArg, key); // Invalid Argument
 
         // Delete References
-        if (isCascadeDelete() && deleteAllReferences(key, conn)==false)
-            return false; // Error deleting referenced records
+        if (isCascadeDelete())
+            deleteAllReferences(key, conn);
         
         // Build SQL-Statement
         DBCommand cmd = db.createCommand();
         // Set key constraints
-        if (!setKeyConstraints(cmd, key))
-        	return false;
-
+        setKeyConstraints(cmd, key);
         // Perform delete
         String sqlCmd = cmd.getDelete(this);
         int affected  = db.executeSQL(sqlCmd, cmd.getParamValues(), conn);
         if (affected < 0)
         { // Delete Failed
-            return error(db);
+            throw new EmpireException(Errors.Internal, "Unexpected return value.");
         } 
         else if (affected == 0)
         { // Record not found
-            return error(DBErrors.RecordDeleteFailed, name);
+            throw new EmpireException(DBErrors.RecordDeleteFailed, name);
         } 
         else if (affected > 1)
         { // Multiple Records affected
-            return error(DBErrors.RecordUpdateInvalid, name);
+            throw new EmpireException(DBErrors.RecordUpdateInvalid, name);
         }
-        // success
-        return success();
     }
 
 }
\ No newline at end of file

Modified: incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java?rev=1148444&r1=1148443&r2=1148444&view=diff
==============================================================================
--- incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java (original)
+++ incubator/empire-db/branches/EMPIREDB-99/empire-db/src/main/java/org/apache/empire/db/DBTableColumn.java Tue Jul 19 16:53:34 2011
@@ -23,6 +23,7 @@ import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import org.apache.empire.EmpireException;
 import org.apache.empire.commons.Attributes;
 import org.apache.empire.commons.Errors;
 import org.apache.empire.data.DataMode;
@@ -208,13 +209,11 @@ public class DBTableColumn extends DBCol
     public void setRequired(boolean required)
     {
         if (isAutoGenerated())
-        {   
-        	// cannot change auto-generated columns
-            error(Errors.NoAccess); 
+        {	// cannot change auto-generated columns
+            throw new EmpireException(Errors.NoAccess); 
         }
         else
-        {
-        	// Set DataMode
+        {	// Set DataMode
         	dataMode=(required ? DataMode.NotNull : DataMode.Nullable);
         }
     }
@@ -261,11 +260,11 @@ public class DBTableColumn extends DBCol
      * @return true if the value is valid or false otherwise.
      */
     @Override
-    public boolean checkValue(Object value)
+    public void checkValue(Object value)
     {
         // Check for NULL
         if (isRequired() && (value == null || value.toString().length() < 1))
-            return error(DBErrors.FieldNotNull, getName());
+            throw new EmpireException(DBErrors.FieldNotNull, getName());
         // Is value valid
         switch (type)
         {
@@ -282,7 +281,7 @@ public class DBTableColumn extends DBCol
                     } catch (ParseException e)
                     {   // Error
                         log.error("checkValue exception: " + e.toString() + " column=" + getName() + " value=" + value);
-                        return error(DBErrors.FieldInvalidDateFormat, getName());
+                        throw new EmpireException(DBErrors.FieldInvalidDateFormat, getName());
                     }
                 }    
                 break;
@@ -299,7 +298,7 @@ public class DBTableColumn extends DBCol
                     } catch (NumberFormatException nfe)
                     {
                         log.error("checkValue exception: " + nfe.toString() + " column=" + getName() + " value=" + value);
-                        return error(DBErrors.FieldNotNumeric, getName());
+                        throw new EmpireException(DBErrors.FieldNotNumeric, getName());
                     }
                 }
                 break;
@@ -315,7 +314,7 @@ public class DBTableColumn extends DBCol
                     } catch (NumberFormatException nfe)
                     {
                         log.error("checkValue exception: " + nfe.toString() + " column=" + getName() + " value=" + String.valueOf(value));
-                        return error(DBErrors.FieldNotNumeric, getName());
+                        throw new EmpireException(DBErrors.FieldNotNumeric, getName());
                     }
                 }
                 break;
@@ -323,7 +322,7 @@ public class DBTableColumn extends DBCol
             case TEXT:
             case CHAR:
                 if (value!=null && value.toString().length() > size)
-                    return error(DBErrors.FieldValueTooLong, getName(), (int)size);
+                    throw new EmpireException(DBErrors.FieldValueTooLong, getName(), (int)size);
                 break;
                 
             default:
@@ -332,7 +331,6 @@ public class DBTableColumn extends DBCol
                 break;
 
         }
-        return success();
     }
 
     /**



Mime
View raw message