empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1213472 - /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
Date Mon, 12 Dec 2011 22:28:51 GMT
Author: doebele
Date: Mon Dec 12 22:28:51 2011
New Revision: 1213472

URL: http://svn.apache.org/viewvc?rev=1213472&view=rev
Log:
EMPIREDB-126
Prepare for commons.BeanUtils 1.8. since setting null will cause an exception (Everything
is fine with 1.7. that is referenced now)

Modified:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java?rev=1213472&r1=1213471&r2=1213472&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/DBRecordData.java
Mon Dec 12 22:28:51 2011
@@ -24,7 +24,7 @@ import java.util.Collection;
 import java.util.Date;
 
 import org.apache.commons.beanutils.BeanUtils;
-import org.apache.empire.commons.DateUtils;
+import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.ColumnExpr;
@@ -290,35 +290,34 @@ public abstract class DBRecordData exten
         {   /*
             if (log.isTraceEnabled())
                 log.trace(bean.getClass().getName() + ": setting property '" + property +
"' to " + String.valueOf(value));
-            */    
+            */
+            /*
             if (value instanceof Date)
-            {   // Patch for Stage Date Bug in BeanUtils
+            {   // Patch for date bug in BeanUtils
                 value = DateUtils.addDate((Date)value, 0, 0, 0);
             }
+            */
             // Set Property Value
-            // Should check whether property exists
-            BeanUtils.setProperty(bean, property, value);
-            // Check result
-            /*
-             * String res = BeanUtils.getProperty(bean, property); if (res!=value &&
res.equals(String.valueOf(value))==false) { //
-             * Property value cannot be set // (missing setter?) String msg = bean.getClass().getName()
+ ": unable to set
-             * property '" + property + "' to " + String.valueOf(value); return error(ERR_INTERNAL,
msg); } else if
-             * (log.isInfoEnabled()) { log.info(bean.getClass().getName() + ": property '"
+ property + "' has been set to " +
-             * res); }
-             */
-            // done
-
+            if (value!=null)
+            {   // Bean utils will convert if necessary
+                BeanUtils.setProperty(bean, property, value);
+            }
+            else
+            {   // Don't convert, just set
+                PropertyUtils.setProperty(bean, property, null);
+            }
+          // IllegalAccessException
         } catch (IllegalAccessException e)
         {   log.error(bean.getClass().getName() + ": unable to set property '" + property
+ "'");
             throw new BeanPropertySetException(bean, property, e);
-            
+          // InvocationTargetException  
         } catch (InvocationTargetException e)
         {   log.error(bean.getClass().getName() + ": unable to set property '" + property
+ "'");
             throw new BeanPropertySetException(bean, property, e);
-            /*
-             * } catch(NoSuchMethodException e) { log.warn(bean.getClass().getName() + ":
cannot check value of property '" +
-             * property + "'"); return true;
-             */
+          // NoSuchMethodException   
+        } catch (NoSuchMethodException e)
+        {   log.error(bean.getClass().getName() + ": unable to set property '" + property
+ "'");
+            throw new BeanPropertySetException(bean, property, e);
         }
     }
 



Mime
View raw message