This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch version3
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/version3 by this push:
     new d1b6152  EMPIREDB-362 DBObject change
d1b6152 is described below

commit d1b615242655eef2ac0042f31f03a213df7821c0
Author: Rainer Döbele <[email protected]>
AuthorDate: Sat Jan 22 22:34:43 2022 +0100

    EMPIREDB-362 DBObject change
---
 .../org/apache/empire/jsf2/app/WebDBContext.java   |  44 +++-
 .../jsf2/pageelements/BeanListPageElement.java     |   3 +-
 .../jsf2/utils/ValueExpressionUnwrapper.java       |   8 +-
 .../java/org/apache/empire/commons/ClassUtils.java | 278 +++++++++++++++++++++
 .../org/apache/empire/commons/ObjectUtils.java     | 180 -------------
 .../main/java/org/apache/empire/db/DBCmdParam.java |   2 +-
 .../main/java/org/apache/empire/db/DBColumn.java   |   2 +-
 .../java/org/apache/empire/db/DBCombinedCmd.java   |   2 +-
 .../main/java/org/apache/empire/db/DBCommand.java  |   5 +-
 .../main/java/org/apache/empire/db/DBDatabase.java |   5 +-
 .../org/apache/empire/db/DBExpressionIndex.java    |   6 +-
 .../main/java/org/apache/empire/db/DBIndex.java    |   7 +-
 .../main/java/org/apache/empire/db/DBObject.java   |  38 ++-
 .../main/java/org/apache/empire/db/DBReader.java   |   6 +-
 .../main/java/org/apache/empire/db/DBRecord.java   |  21 +-
 .../main/java/org/apache/empire/db/DBRelation.java |   6 +-
 .../main/java/org/apache/empire/db/DBRowSet.java   |  37 +--
 .../apache/empire/db/context/DBContextStatic.java  |   2 +-
 .../empire/db/context/DBRollbackManager.java       |  13 +
 .../empire/db/driver/oracle/OracleRowNumExpr.java  |   5 +-
 .../empire/db/expr/column/DBAbstractFuncExpr.java  |   2 +-
 .../apache/empire/db/expr/column/DBAliasExpr.java  |   2 +-
 .../apache/empire/db/expr/column/DBCalcExpr.java   |   2 +-
 .../apache/empire/db/expr/column/DBCaseExpr.java   |   2 +-
 .../empire/db/expr/column/DBCaseWhenExpr.java      |   2 +-
 .../apache/empire/db/expr/column/DBConcatExpr.java |   2 +-
 .../apache/empire/db/expr/column/DBCountExpr.java  |   2 +-
 .../apache/empire/db/expr/column/DBScalarExpr.java |   5 +-
 .../apache/empire/db/expr/column/DBValueExpr.java  |   5 +-
 .../empire/db/expr/compare/DBCompareAndOrExpr.java |   2 +-
 .../empire/db/expr/compare/DBCompareColExpr.java   |   2 +-
 .../empire/db/expr/compare/DBCompareNotExpr.java   |   2 +-
 .../empire/db/expr/compare/DBExistsExpr.java       |   2 +-
 .../empire/db/expr/compare/DBParenthesisExpr.java  |   2 +-
 .../empire/db/expr/join/DBColumnJoinExpr.java      |   2 +-
 .../empire/db/expr/join/DBCrossJoinExpr.java       |   2 +-
 .../apache/empire/db/expr/order/DBOrderByExpr.java |   2 +-
 .../org/apache/empire/db/expr/set/DBSetExpr.java   |   2 +-
 38 files changed, 445 insertions(+), 267 deletions(-)

diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
index 2cecdd9..aba73a2 100644
--- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
+++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/WebDBContext.java
@@ -1,14 +1,20 @@
 package org.apache.empire.jsf2.app;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
 import java.sql.Connection;
 
 import javax.faces.context.FacesContext;
 
+import org.apache.empire.commons.ClassUtils;
 import org.apache.empire.db.DBCommand;
 import org.apache.empire.db.DBDatabase;
 import org.apache.empire.db.DBDatabaseDriver;
 import org.apache.empire.db.context.DBContextBase;
 import org.apache.empire.db.context.DBRollbackManager;
+import org.apache.empire.exceptions.ItemNotFoundException;
 import org.apache.empire.exceptions.NotSupportedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,14 +27,44 @@ import org.slf4j.LoggerFactory;
  *
  * @param <DB>
  */
-public class WebDBContext<DB extends DBDatabase> extends DBContextBase
+public class WebDBContext<DB extends DBDatabase> extends DBContextBase 
implements Serializable
 {
+    private static final long serialVersionUID = 1L;
+
     private static final Logger    log = 
LoggerFactory.getLogger(WebDBContext.class);
 
-    private final WebApplication   app;
-    private final DBDatabaseDriver driver;
-    private final DB               database;
+    protected final transient WebApplication   app;
+    protected final transient DB               database;
+    protected final transient DBDatabaseDriver driver;
 
+    /**
+    * Custom serialization for transient fields.
+    */
+    private void writeObject(ObjectOutputStream strm) throws IOException 
+    {   // Database
+        strm.writeObject((database!=null ? database.getIdentifier() : ""));
+        // write the rest
+        strm.defaultWriteObject();
+    }
+    
+    /**
+    * Custom deserialization for transient fields.
+    */
+    private void readObject(ObjectInputStream strm) 
+        throws IOException, ClassNotFoundException
+    {   // WebApplication
+        ClassUtils.setPrivateFieldValue(WebDBContext.class, this, "app", 
WebApplication.getInstance());
+        // Database
+        String dbid = String.valueOf(strm.readObject());
+        DBDatabase database = DBDatabase.findById(dbid);
+        if (database==null)
+            throw new ItemNotFoundException(dbid);
+        ClassUtils.setPrivateFieldValue(WebDBContext.class, this, "database", 
database);
+        ClassUtils.setPrivateFieldValue(WebDBContext.class, this, "driver",   
database.getDriver());
+        // read the rest
+        strm.defaultReadObject();
+    }
+    
     public WebDBContext(WebApplication app, DB db)
     {
         this.app = app;
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
index 309ea44..db333ec 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/BeanListPageElement.java
@@ -638,9 +638,8 @@ public class BeanListPageElement<T> extends 
ListPageElement<T> implements ListIt
                 keyExpr = keyExpr.append(pk[i]);
             }
             
-            String[] keys = new String[items.size()];
+            Object[] keys = new Object[items.size()];
             int i = 0;
-
             for (Object[] item : items)
             {
                 keys[i++] = StringUtils.arrayToString(item, "");
diff --git 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ValueExpressionUnwrapper.java
 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ValueExpressionUnwrapper.java
index d3b0521..505e22f 100644
--- 
a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ValueExpressionUnwrapper.java
+++ 
b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/ValueExpressionUnwrapper.java
@@ -21,7 +21,7 @@ package org.apache.empire.jsf2.utils;
 import javax.el.ValueExpression;
 import javax.el.VariableMapper;
 
-import org.apache.empire.commons.ObjectUtils;
+import org.apache.empire.commons.ClassUtils;
 import org.apache.empire.commons.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -84,15 +84,15 @@ public class ValueExpressionUnwrapper
             {   // expected: ve = org.apache.el.ValueExpressionImpl
                 if 
(ve.getClass().getName().equals("org.apache.el.ValueExpressionImpl"))
                 {   // get the Node
-                    Object node = ObjectUtils.invokeSimplePrivateMethod(ve, 
"getNode");
+                    Object node = ClassUtils.invokeSimplePrivateMethod(ve, 
"getNode");
                     if (node!=null)
                     {   // We have a Node
                         // Now get the Image
-                        String image = 
StringUtils.toString(ObjectUtils.invokeSimpleMethod(node, "getImage"));
+                        String image = 
StringUtils.toString(ClassUtils.invokeSimpleMethod(node, "getImage"));
                         if (StringUtils.isNotEmpty(image)) 
                         {   // We have an image
                             // Now find the varMapper
-                            VariableMapper varMapper = 
(VariableMapper)ObjectUtils.getPrivateFieldValue(ve, "varMapper");
+                            VariableMapper varMapper = 
(VariableMapper)ClassUtils.getPrivateFieldValue(ve, "varMapper");
                             if (varMapper!=null)
                             {   // Resolve variable using mapper
                                 ve = varMapper.resolveVariable(image);
diff --git a/empire-db/src/main/java/org/apache/empire/commons/ClassUtils.java 
b/empire-db/src/main/java/org/apache/empire/commons/ClassUtils.java
new file mode 100644
index 0000000..34778c2
--- /dev/null
+++ b/empire-db/src/main/java/org/apache/empire/commons/ClassUtils.java
@@ -0,0 +1,278 @@
+/*
+ * 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.commons;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.empire.exceptions.EmpireException;
+import org.apache.empire.exceptions.InternalException;
+import org.apache.empire.exceptions.InvalidArgumentException;
+import org.apache.empire.exceptions.NotSupportedException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class ClassUtils
+{
+    // Logger
+    private static final Logger log = 
LoggerFactory.getLogger(ClassUtils.class);
+    
+    /*
+     * ClassUtils contains static methods only
+     */
+    private ClassUtils()
+    { 
+        /* No instances */
+    }
+
+    /**
+     * Used to test Serialization
+     * @param objToSerialize
+     * @return
+     */
+    @SuppressWarnings("unchecked")
+    public static <T> T testSerialization(Class<T> clazz, Object 
objToSerialize)
+    {
+        try
+        {   ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            // Write the object
+            ObjectOutputStream oos = new ObjectOutputStream(baos);
+            oos.writeObject(objToSerialize);
+            // Read the object
+            ObjectInputStream oin = new ObjectInputStream(new 
ByteArrayInputStream(baos.toByteArray()));
+            Object unserializedObject = oin.readObject();
+            // return result
+            return (T)unserializedObject;
+        }
+        catch (IOException e)
+        {
+            log.error("Serialization failed: "+e.getMessage(), e);
+            throw new InternalException(e);
+        }
+        catch (ClassNotFoundException e)
+        {
+            log.error("Class not Found: "+e.getMessage(), e);
+            throw new InternalException(e);
+        }
+    }
+    
+    /**
+     * Retrieve a field value using reflection
+     * @param clazz the class from which to obtain the field
+     * @param object the object instance from which to obtain the field
+     * @param property the property to obtain 
+     * @param includePrivateFields flag whether or not to include private 
fields
+     * @return the property value
+     */
+    public static synchronized Object getFieldValue(Class<?> clazz, Object 
object, String property, boolean includePrivateFields)
+    {
+        // check arguments
+        if (clazz==null || (object!=null && !clazz.isInstance(object)))
+            throw new InvalidArgumentException("clazz", clazz);
+        if (StringUtils.isEmpty(property))
+            throw new InvalidArgumentException("property", property);
+        // begin
+        boolean accessible = true; 
+        Field field = null;
+        try
+        { // find and invoke
+            field = (includePrivateFields ? clazz.getDeclaredField(property) : 
clazz.getField(property));
+            accessible = field.isAccessible();
+            if (includePrivateFields && accessible==false)
+                field.setAccessible(true);
+            // invoke
+            return field.get(object);
+        }
+        catch (NoSuchFieldException e)
+        {   // No such Method
+            if (includePrivateFields)
+            {   // try superclass
+                clazz = clazz.getSuperclass();
+                if (clazz!=null && !clazz.equals(java.lang.Object.class))
+                    return getFieldValue(clazz, object, property, true);
+            }
+            // not found
+            return null;
+        }
+        catch (IllegalAccessException e)
+        {   // Invalid Method definition   
+            throw new NotSupportedException(object, property, e);
+        }
+        finally {
+            // restore accessible
+            if (field!=null && accessible==false)
+                field.setAccessible(false);
+        }
+    }
+
+    /**
+     * Retrieve a field value using reflection
+     * The field accessor must be public
+     * @param object the object instance from which to obtain the field
+     * @param property the property to obtain 
+     * @return the property value
+     */
+    public static Object getFieldValue(Object object, String property)
+    {
+        if (object==null)
+            throw new InvalidArgumentException("object", object);
+        // begin
+        return getFieldValue(object.getClass(), object, property, false);
+    }
+
+    /**
+     * Retrieve a field value using reflection 
+     * @param object the object instance from which to obtain the field
+     * @param property the property to obatin 
+     * @return the property value
+     */
+    public static Object getPrivateFieldValue(Object object, String property)
+    {
+        if (object==null)
+            throw new InvalidArgumentException("object", object);
+        // begin
+        return getFieldValue(object.getClass(), object, property, true);
+    }
+
+    /**
+     * Retrieve a field value using reflection 
+     * @param clazz the class of the object
+     * @param object the object or null if static fields are to be changed
+     * @param property the field name
+     * @param value the field value
+     */
+    public static synchronized void setPrivateFieldValue(Class<?> clazz, 
Object object, String property, Object value)
+    {
+        try
+        {
+            Field field = clazz.getDeclaredField(property);
+            field.setAccessible(true);
+            // Object val = field.get(object);
+            field.set(object, value);
+            field.setAccessible(false);
+        }
+        catch (Exception e)
+        {   // Access Error
+            log.error("Unable to modify private field '"+property+"* on class 
'"+clazz.getName()+"'", e);
+            throw new InternalException(e);
+        }
+    }
+    
+    /**
+     * Invoke a simple method (without parameters) on an object using 
reflection
+     * @param clazz the class from which to obtain the field
+     * @param object the object instance on which to invoke the method
+     * @param methodName the name of the method to invoke 
+     * @param includePrivateMethods flag whether or not to include private 
methods
+     * @return the return value of the method
+     */
+    public static synchronized Object invokeSimpleMethod(Class<?> clazz, 
Object object, String methodName, boolean includePrivateMethods)
+    {
+        // check arguments
+        if (object==null)
+            throw new InvalidArgumentException("object", object);
+        if (clazz==null || !clazz.isInstance(object))
+            throw new InvalidArgumentException("clazz", clazz);
+        if (StringUtils.isEmpty(methodName))
+            throw new InvalidArgumentException("methodName", methodName);
+        // begin
+        boolean accessible = true; 
+        Method method = null;
+        try
+        { // find and invoke
+            method = (includePrivateMethods ? 
clazz.getDeclaredMethod(methodName) : clazz.getMethod(methodName));
+            accessible = method.isAccessible();
+            if (includePrivateMethods && accessible==false)
+                method.setAccessible(true);
+            // invoke
+            return method.invoke(object);
+        }
+        catch (NoSuchMethodException e)
+        {   // No such Method
+            if (includePrivateMethods)
+            {   // try superclass
+                clazz = clazz.getSuperclass();
+                if (clazz!=null && !clazz.equals(java.lang.Object.class))
+                    return invokeSimpleMethod(clazz, object, methodName, true);
+            }
+            // not found
+            return null;
+        }
+        catch (SecurityException e)
+        {   // Invalid Method definition   
+            throw new NotSupportedException(object, methodName, e);
+        }
+        catch (IllegalAccessException e)
+        {   // Invalid Method definition   
+            throw new NotSupportedException(object, methodName, e);
+        }
+        catch (IllegalArgumentException e)
+        {   // Invalid Method definition   
+            throw new NotSupportedException(object, methodName, e);
+        }
+        catch (InvocationTargetException e)
+        {   // Error inside Method
+            Throwable cause = e.getCause();
+            if (cause instanceof EmpireException)
+                throw (EmpireException)cause;
+            // wrap    
+            throw new InternalException(cause);
+        }
+        finally {
+            // restore accessible
+            if (method!=null && accessible==false)
+                method.setAccessible(false);
+        }
+    }
+
+    /**
+     * Invoke a simple method (without parameters) on an object using 
reflection
+     * @param object the object instance on which to invoke the method
+     * @param methodName the name of the method to invoke 
+     * @return the return value of the method
+     */
+    public static Object invokeSimpleMethod(Object object, String methodName)
+    {
+        if (object==null)
+            throw new InvalidArgumentException("object", object);
+        // begin
+        return invokeSimpleMethod(object.getClass(), object, methodName, 
false);
+    }
+
+    /**
+     * Invoke a simple method (without parameters) on an object using 
reflection
+     * @param object the object instance on which to invoke the method
+     * @param methodName the name of the method to invoke 
+     * @return the return value of the method
+     */
+    public static Object invokeSimplePrivateMethod(Object object, String 
methodName)
+    {
+        if (object==null)
+            throw new InvalidArgumentException("object", object);
+        // begin
+        return invokeSimpleMethod(object.getClass(), object, methodName, true);
+    }
+
+}
diff --git a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java 
b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
index 5163fb7..d6d8bef 100644
--- a/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
+++ b/empire-db/src/main/java/org/apache/empire/commons/ObjectUtils.java
@@ -19,9 +19,6 @@
 package org.apache.empire.commons;
 
 import java.io.Serializable;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.text.ParseException;
@@ -37,12 +34,8 @@ import java.util.List;
 import java.util.Locale;
 
 import org.apache.commons.beanutils.MethodUtils;
-import org.apache.empire.exceptions.EmpireException;
-import org.apache.empire.exceptions.InternalException;
-import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.InvalidValueException;
 import org.apache.empire.exceptions.ItemNotFoundException;
-import org.apache.empire.exceptions.NotSupportedException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -965,178 +958,5 @@ public final class ObjectUtils
         }
         return false;
     }
-
-    /**
-     * Retrieve a field value using reflection
-     * @param clazz the class from which to obtain the field
-     * @param object the object instance from which to obtain the field
-     * @param property the property to obtain 
-     * @param includePrivateFields flag whether or not to include private 
fields
-     * @return the property value
-     */
-    public static synchronized Object getFieldValue(Class<?> clazz, Object 
object, String property, boolean includePrivateFields)
-    {
-        // check arguments
-        if (clazz==null || (object!=null && !clazz.isInstance(object)))
-            throw new InvalidArgumentException("clazz", clazz);
-        if (StringUtils.isEmpty(property))
-            throw new InvalidArgumentException("property", property);
-        // begin
-        boolean accessible = true; 
-        Field field = null;
-        try
-        { // find and invoke
-            field = (includePrivateFields ? clazz.getDeclaredField(property) : 
clazz.getField(property));
-            accessible = field.isAccessible();
-            if (includePrivateFields && accessible==false)
-                field.setAccessible(true);
-            // invoke
-            return field.get(object);
-        }
-        catch (NoSuchFieldException e)
-        {   // No such Method
-            if (includePrivateFields)
-            {   // try superclass
-                clazz = clazz.getSuperclass();
-                if (clazz!=null && !clazz.equals(java.lang.Object.class))
-                    return getFieldValue(clazz, object, property, true);
-            }
-            // not found
-            return null;
-        }
-        catch (IllegalAccessException e)
-        {   // Invalid Method definition   
-            throw new NotSupportedException(object, property, e);
-        }
-        finally {
-            // restore accessible
-            if (field!=null && accessible==false)
-                field.setAccessible(false);
-        }
-    }
-
-    /**
-     * Retrieve a field value using reflection
-     * The field accessor must be public
-     * @param object the object instance from which to obtain the field
-     * @param property the property to obtain 
-     * @return the property value
-     */
-    public static Object getFieldValue(Object object, String property)
-    {
-        if (object==null)
-            throw new InvalidArgumentException("object", object);
-        // begin
-        return getFieldValue(object.getClass(), object, property, false);
-    }
-
-    /**
-     * Retrieve a field value using reflection 
-     * @param object the object instance from which to obtain the field
-     * @param property the property to obatin 
-     * @return the property value
-     */
-    public static Object getPrivateFieldValue(Object object, String property)
-    {
-        if (object==null)
-            throw new InvalidArgumentException("object", object);
-        // begin
-        return getFieldValue(object.getClass(), object, property, true);
-    }
-    
-    /**
-     * Invoke a simple method (without parameters) on an object using 
reflection
-     * @param clazz the class from which to obtain the field
-     * @param object the object instance on which to invoke the method
-     * @param methodName the name of the method to invoke 
-     * @param includePrivateMethods flag whether or not to include private 
methods
-     * @return the return value of the method
-     */
-    public static synchronized Object invokeSimpleMethod(Class<?> clazz, 
Object object, String methodName, boolean includePrivateMethods)
-    {
-        // check arguments
-        if (object==null)
-            throw new InvalidArgumentException("object", object);
-        if (clazz==null || !clazz.isInstance(object))
-            throw new InvalidArgumentException("clazz", clazz);
-        if (StringUtils.isEmpty(methodName))
-            throw new InvalidArgumentException("methodName", methodName);
-        // begin
-        boolean accessible = true; 
-        Method method = null;
-        try
-        { // find and invoke
-            method = (includePrivateMethods ? 
clazz.getDeclaredMethod(methodName) : clazz.getMethod(methodName));
-            accessible = method.isAccessible();
-            if (includePrivateMethods && accessible==false)
-                method.setAccessible(true);
-            // invoke
-            return method.invoke(object);
-        }
-        catch (NoSuchMethodException e)
-        {   // No such Method
-            if (includePrivateMethods)
-            {   // try superclass
-                clazz = clazz.getSuperclass();
-                if (clazz!=null && !clazz.equals(java.lang.Object.class))
-                    return invokeSimpleMethod(clazz, object, methodName, true);
-            }
-            // not found
-            return null;
-        }
-        catch (SecurityException e)
-        {   // Invalid Method definition   
-            throw new NotSupportedException(object, methodName, e);
-        }
-        catch (IllegalAccessException e)
-        {   // Invalid Method definition   
-            throw new NotSupportedException(object, methodName, e);
-        }
-        catch (IllegalArgumentException e)
-        {   // Invalid Method definition   
-            throw new NotSupportedException(object, methodName, e);
-        }
-        catch (InvocationTargetException e)
-        {   // Error inside Method
-            Throwable cause = e.getCause();
-            if (cause instanceof EmpireException)
-                throw (EmpireException)cause;
-            // wrap    
-            throw new InternalException(cause);
-        }
-        finally {
-            // restore accessible
-            if (method!=null && accessible==false)
-                method.setAccessible(false);
-        }
-    }
-
-    /**
-     * Invoke a simple method (without parameters) on an object using 
reflection
-     * @param object the object instance on which to invoke the method
-     * @param methodName the name of the method to invoke 
-     * @return the return value of the method
-     */
-    public static Object invokeSimpleMethod(Object object, String methodName)
-    {
-        if (object==null)
-            throw new InvalidArgumentException("object", object);
-        // begin
-        return invokeSimpleMethod(object.getClass(), object, methodName, 
false);
-    }
-
-    /**
-     * Invoke a simple method (without parameters) on an object using 
reflection
-     * @param object the object instance on which to invoke the method
-     * @param methodName the name of the method to invoke 
-     * @return the return value of the method
-     */
-    public static Object invokeSimplePrivateMethod(Object object, String 
methodName)
-    {
-        if (object==null)
-            throw new InvalidArgumentException("object", object);
-        // begin
-        return invokeSimpleMethod(object.getClass(), object, methodName, true);
-    }
     
 }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java 
b/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
index 68323b0..c787102 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
@@ -106,7 +106,7 @@ public class DBCmdParam extends DBExpr
     }
     
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return cmd.getDatabase();
     }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java 
b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
index d23e09d..27f08b9 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBColumn.java
@@ -244,7 +244,7 @@ public abstract class DBColumn extends DBColumnExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return (rowset!=null ? rowset.getDatabase() : null);
     }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java 
b/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
index 024b7ca..d9d48ad 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCombinedCmd.java
@@ -66,7 +66,7 @@ public class DBCombinedCmd extends DBCommandExpr
    * @return the current DBDatabase object
    */
    @Override
-   public DBDatabase getDatabase()
+   public final <T extends DBDatabase> T getDatabase()
    {
       return left.getDatabase();
    }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java 
b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
index 42125a2..5c1fffd 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCommand.java
@@ -230,10 +230,11 @@ public abstract class DBCommand extends DBCommandExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
 
     @Override
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java 
b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
index 02c20c9..a05a516 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBDatabase.java
@@ -412,10 +412,11 @@ public abstract class DBDatabase extends DBObject
     /**
      * @see org.apache.empire.db.DBObject#getDatabase()
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return this;
+        return (T)(this);
     }
 
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java 
b/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
index 99870eb..f8777be 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBExpressionIndex.java
@@ -56,12 +56,12 @@ public class DBExpressionIndex extends DBIndex
     {
         this(name, (unique ? DBIndexType.UNIQUE : DBIndexType.STANDARD), 
columnExpressions);
     }
-
     
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public <T extends DBDatabase> T getDatabase()
     {
-        return columnExpressions[0].getDatabase();
+        return (T)(columnExpressions[0].getDatabase());
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBIndex.java 
b/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
index e1beb1f..ad15237 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBIndex.java
@@ -87,11 +87,12 @@ public class DBIndex extends DBObject
     {
         this.table = table;
     }
-
+    
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public <T extends DBDatabase> T getDatabase()
     {
-        return (table!=null) ? table.getDatabase() : null;
+        return (table!=null) ? (T)table.getDatabase() : null;
     }
 
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBObject.java 
b/empire-db/src/main/java/org/apache/empire/db/DBObject.java
index 8bef177..aca6366 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBObject.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBObject.java
@@ -18,9 +18,14 @@
  */
 package org.apache.empire.db;
 
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
 // java.sql
 import java.io.Serializable;
 
+import org.apache.empire.commons.StringUtils;
+
 
 /**
  * Base class for all objects that directly or indirectly belong to a database 
including the database object itself.
@@ -39,7 +44,38 @@ public abstract class DBObject implements Serializable
      * 
      * @return the database object
      */
-    public abstract DBDatabase getDatabase();
+    public abstract <T extends DBDatabase> T getDatabase();
+    
+    
+    /**
+     * Serialize transient database
+     * @param strm the stream
+     * @param db
+     * @throws IOException
+     */
+    protected void writeDatabase(ObjectOutputStream strm, DBDatabase db) 
throws IOException
+    {
+        String dbid = (db!=null ? db.getIdentifier() : ""); 
+        strm.writeObject(dbid);
+    }
+    
+    /**
+     * Serialize transient database
+     * @param strm the stream
+     * @param db
+     * @throws IOException
+     */
+    protected DBDatabase readDatabase(ObjectInputStream strm) throws 
IOException, ClassNotFoundException
+    {
+        String dbid = String.valueOf(strm.readObject());
+        if (StringUtils.isEmpty(dbid))
+            return null; // No Database
+        // find database
+        DBDatabase sdb = DBDatabase.findById(dbid);
+        if (sdb==null)
+            throw new ClassNotFoundException(dbid);
+        return sdb;
+    }
 
     /*
     private void readObject(ObjectInputStream strm) throws IOException, 
ClassNotFoundException,
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBReader.java 
b/empire-db/src/main/java/org/apache/empire/db/DBReader.java
index 63dcff1..94ba878 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBReader.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBReader.java
@@ -290,10 +290,12 @@ public class DBReader extends DBRecordData implements 
DBContextAware
      * 
      * @return the current DBDatabase object
      */
+    
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return this.db;
+        return (T)db;
     }
     
     public boolean getScrollable()
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
index a5b0005..4153caa 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRecord.java
@@ -296,9 +296,9 @@ public class DBRecord extends DBRecordData implements 
DBContextAware, Record, Cl
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return rowset.db;
+        return rowset.getDatabase();
     }
 
     /**
@@ -642,11 +642,6 @@ public class DBRecord extends DBRecordData implements 
DBContextAware, Record, Cl
             boolean numeric = column.getDataType().isNumeric();
             value = ObjectUtils.getEnumValue(enumVal, numeric);
         }
-        // Is Value valid?
-        if (this.validateFieldValues)
-        {   // validate
-            value = validateValue(column, value);
-        }
         // Has Value changed?
         if (ObjectUtils.compareEqual(current, value))
         {   // value has not changed!
@@ -657,6 +652,18 @@ public class DBRecord extends DBRecordData implements 
DBContextAware, Record, Cl
         {   // Read Only column may be set
             throw new FieldIsReadOnlyException(column);
         }
+        // Is Value valid?
+        if (this.validateFieldValues)
+        {   // validate
+            Object validated = validateValue(column, value);
+            if (value != validated)
+            {   // Value has been converted, check again
+                if (ObjectUtils.compareEqual(current, validated))
+                    return; 
+                // user converted value
+                value = validated;
+            }
+        }
         // Init original values
         modifyValue(index, value, true);
     }
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRelation.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
index 884281f..3f933e8 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRelation.java
@@ -162,11 +162,11 @@ public class DBRelation extends DBObject
         return (DBTable)references[0].getTargetColumn().getRowSet();
     }
     
-
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
     
     /**
diff --git a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java 
b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
index 545a22e..86a6386 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBRowSet.java
@@ -21,7 +21,6 @@ package org.apache.empire.db;
 import java.io.IOException;
 import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
-import java.lang.reflect.Field;
 import java.sql.Connection;
 import java.sql.Timestamp;
 import java.util.ArrayList;
@@ -32,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.apache.empire.commons.ClassUtils;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
@@ -161,16 +161,8 @@ public abstract class DBRowSet extends DBExpr
     */
     private void writeObject(ObjectOutputStream strm) throws IOException 
     {
-        if (db==null)
-        {   // No database
-            strm.writeObject("");
-            strm.defaultWriteObject();
-            return;
-        }
-        String dbid = db.getIdentifier(); 
+        String dbid = (db!=null ? db.getIdentifier() : ""); 
         strm.writeObject(dbid);
-        if (log.isDebugEnabled())
-            log.debug("Serialization: writing DBRowSet "+dbid);
         // write the rest
         strm.defaultWriteObject();
     }
@@ -178,24 +170,12 @@ public abstract class DBRowSet extends DBExpr
     /**
     * Custom deserialization for transient database.
     */
-    private void readObject(ObjectInputStream strm) throws IOException, 
ClassNotFoundException,
-        SecurityException, NoSuchFieldException, IllegalArgumentException, 
IllegalAccessException
+    private void readObject(ObjectInputStream strm) throws IOException, 
ClassNotFoundException
     {
+        // Database
         String dbid = String.valueOf(strm.readObject());
-        if (StringUtils.isNotEmpty(dbid))
-        {   // Find database
-            if (log.isDebugEnabled())
-                log.debug("Serialization: reading DBRowSet "+dbid);
-            // find database
-            DBDatabase sdb = DBDatabase.findById(dbid);
-            if (sdb==null)
-                throw new ClassNotFoundException(dbid);
-            // set final field
-            Field f = DBRowSet.class.getDeclaredField("db");
-            f.setAccessible(true);
-            f.set(this, sdb);
-            f.setAccessible(false);
-        }    
+        DBDatabase database = DBDatabase.findById(dbid);
+        ClassUtils.setPrivateFieldValue(DBRowSet.class, this, "db", database);
         // read the rest
         strm.defaultReadObject();
     }
@@ -280,10 +260,11 @@ public abstract class DBRowSet extends DBExpr
      * <P>
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public final DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
 
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/context/DBContextStatic.java 
b/empire-db/src/main/java/org/apache/empire/db/context/DBContextStatic.java
index 3da00cb..e9ca030 100644
--- a/empire-db/src/main/java/org/apache/empire/db/context/DBContextStatic.java
+++ b/empire-db/src/main/java/org/apache/empire/db/context/DBContextStatic.java
@@ -45,7 +45,7 @@ public class DBContextStatic extends DBContextBase
      */
     public DBContextStatic(DBDatabaseDriver driver, Connection conn)
     {
-        this(driver, conn, true, false);
+        this(driver, conn, (conn!=null), false);
     }
     
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/context/DBRollbackManager.java 
b/empire-db/src/main/java/org/apache/empire/db/context/DBRollbackManager.java
index a41041e..49d36a9 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/context/DBRollbackManager.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/context/DBRollbackManager.java
@@ -24,6 +24,7 @@ import java.util.LinkedHashMap;
 import java.util.Map;
 
 import org.apache.empire.db.DBObject;
+import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.ObjectNotValidException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -58,6 +59,10 @@ public class DBRollbackManager
      */
     public synchronized void appendHandler(Connection conn, DBRollbackHandler 
handler)
     {
+        if (conn==null)
+        {   // Oops, no connection
+            throw new InvalidArgumentException("conn", conn);
+        }
         Map<DBObject, DBRollbackHandler> handlerMap = 
connectionMap.get(conn.hashCode());
         if (handlerMap==null)
         {   handlerMap = new LinkedHashMap<DBObject, 
DBRollbackHandler>(this.initialObjectCapacity);
@@ -84,6 +89,10 @@ public class DBRollbackManager
      */
     public synchronized void removeHandler(Connection conn, DBObject object)
     {
+        if (conn==null)
+        {   // Oops, no connection
+            return;
+        }
         if (object==null)
         {   // Discard all
             releaseConnection(conn, ReleaseAction.Discard);
@@ -107,6 +116,10 @@ public class DBRollbackManager
      */
     public synchronized void releaseConnection(Connection conn, ReleaseAction 
action)
     {
+        if (conn==null)
+        {   // Oops, no connection
+            return;
+        }
         Map<DBObject, DBRollbackHandler> handlerMap = 
connectionMap.get(conn.hashCode());
         if (handlerMap==null)
             return; // Nothing to do
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/driver/oracle/OracleRowNumExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/driver/oracle/OracleRowNumExpr.java
index eeb93b8..0f4f7f9 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/driver/oracle/OracleRowNumExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/driver/oracle/OracleRowNumExpr.java
@@ -55,10 +55,11 @@ public class OracleRowNumExpr extends DBColumnExpr
      * Returns the current DBDatabase object.
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
 
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAbstractFuncExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAbstractFuncExpr.java
index 100ecd0..cb09433 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAbstractFuncExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAbstractFuncExpr.java
@@ -86,7 +86,7 @@ public abstract class DBAbstractFuncExpr extends DBColumnExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAliasExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAliasExpr.java
index 3ab8d35..a319b01 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAliasExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBAliasExpr.java
@@ -68,7 +68,7 @@ public class DBAliasExpr extends DBColumnExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
index f68239a..d6a69e9 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCalcExpr.java
@@ -67,7 +67,7 @@ public class DBCalcExpr extends DBColumnExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseExpr.java
index 44392a0..8b38bf6 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseExpr.java
@@ -58,7 +58,7 @@ public class DBCaseExpr extends DBColumnExpr
     }
 
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return trueExpr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseWhenExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseWhenExpr.java
index 5b0b766..cef0a24 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseWhenExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCaseWhenExpr.java
@@ -60,7 +60,7 @@ public class DBCaseWhenExpr extends DBColumnExpr
     }
 
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return getFirstColumnExpr().getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBConcatExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBConcatExpr.java
index 2ce7bf6..d9e35ce 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBConcatExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBConcatExpr.java
@@ -58,7 +58,7 @@ public class DBConcatExpr extends DBColumnExpr
     }
 
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return left.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
index c0f8760..f3cb299 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBCountExpr.java
@@ -77,7 +77,7 @@ public class DBCountExpr extends DBColumnExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         if (column!=null)
             return column.getDatabase();
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBScalarExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBScalarExpr.java
index 574aab4..c3ff924 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBScalarExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBScalarExpr.java
@@ -97,10 +97,11 @@ public class DBScalarExpr extends DBColumnExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
 
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java
index 9161fa9..443f3d2 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/column/DBValueExpr.java
@@ -101,10 +101,11 @@ public class DBValueExpr extends DBColumnExpr
      * 
      * @return the current DBDatabase object
      */
+    @SuppressWarnings("unchecked")
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
-        return db;
+        return (T)db;
     }
 
     /**
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
index c6a99ac..aeb4a37 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareAndOrExpr.java
@@ -75,7 +75,7 @@ public class DBCompareAndOrExpr extends DBCompareExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return left.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
index 963bfe4..a203873 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareColExpr.java
@@ -69,7 +69,7 @@ public class DBCompareColExpr extends DBCompareExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
index 8f9d298..ea34a2a 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBCompareNotExpr.java
@@ -54,7 +54,7 @@ public class DBCompareNotExpr extends DBCompareExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
index ede0065..3b6ea96 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBExistsExpr.java
@@ -70,7 +70,7 @@ public class DBExistsExpr extends DBCompareExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return cmd.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
index f61ec7e..b264572 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/compare/DBParenthesisExpr.java
@@ -43,7 +43,7 @@ public class DBParenthesisExpr extends DBCompareExpr
     }
 
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return wrap.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBColumnJoinExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBColumnJoinExpr.java
index e35c2b2..e5680d4 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBColumnJoinExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBColumnJoinExpr.java
@@ -61,7 +61,7 @@ public class DBColumnJoinExpr extends DBJoinExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return left.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
index 0c06e31..c4fbe10 100644
--- 
a/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
+++ 
b/empire-db/src/main/java/org/apache/empire/db/expr/join/DBCrossJoinExpr.java
@@ -63,7 +63,7 @@ public class DBCrossJoinExpr extends DBJoinExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return left.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/order/DBOrderByExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/order/DBOrderByExpr.java
index 67ffc9b..113bd64 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/order/DBOrderByExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/order/DBOrderByExpr.java
@@ -69,7 +69,7 @@ public class DBOrderByExpr extends DBExpr
      * @see org.apache.empire.db.DBExpr#getDatabase()
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return expr.getDatabase();
     }
diff --git 
a/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java 
b/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
index c6fc225..d6241dc 100644
--- a/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
+++ b/empire-db/src/main/java/org/apache/empire/db/expr/set/DBSetExpr.java
@@ -63,7 +63,7 @@ public class DBSetExpr extends DBExpr
      * @return the current DBDatabase object
      */
     @Override
-    public DBDatabase getDatabase()
+    public final <T extends DBDatabase> T getDatabase()
     {
         return column.getDatabase();
     }

Reply via email to