commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils BasicResultSetConverter.java
Date Fri, 17 Oct 2003 23:22:44 GMT
dgraham     2003/10/17 16:22:44

  Modified:    dbutils/src/java/org/apache/commons/dbutils
                        BasicResultSetConverter.java
  Log:
  Ignore null column values for primitive types instead of setting the bean
  property to the default value for the primitive.   This allows any defaults
  set in the bean class to not get overwritten.  If the bean doesn't define
  a special default value it would be set to the primitive default anyway.
  
  Revision  Changes    Path
  1.4       +7 -23     jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/BasicResultSetConverter.java
  
  Index: BasicResultSetConverter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/dbutils/src/java/org/apache/commons/dbutils/BasicResultSetConverter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BasicResultSetConverter.java	16 Oct 2003 05:00:20 -0000	1.3
  +++ BasicResultSetConverter.java	17 Oct 2003 23:22:44 -0000	1.4
  @@ -98,24 +98,7 @@
        */
       private static final BasicResultSetConverter instance =
           new BasicResultSetConverter();
  -
  -    /**
  -     * If a column was null, and the bean property is a primitive type, set
  -     * the property to the default value for its type. 
  -     */
  -    private static final Map defaultValues = new HashMap();
  -
  -    static {
  -        defaultValues.put(int.class, new Integer(0));
  -        defaultValues.put(short.class, new Short((short) 0));
  -        defaultValues.put(byte.class, new Byte((byte) 0));
  -        defaultValues.put(float.class, new Float(0f));
  -        defaultValues.put(double.class, new Double(0.0));
  -        defaultValues.put(long.class, new Long(0L));
  -        defaultValues.put(boolean.class, Boolean.FALSE);
  -        defaultValues.put(char.class, new Character('\u0000'));
  -    }
  -    
  +   
       /**
        * Returns the Singleton instance of this class.
        */
  @@ -162,10 +145,11 @@
                       Object value = rs.getObject(i);
   
                       if (rs.wasNull() && pd[j].getPropertyType().isPrimitive())
{
  -                        value = defaultValues.get(pd[j].getPropertyType());
  +                        continue;
                       }
   
                       callSetter(pd[j], obj, value);
  +                    break;
                   }
               }
           }
  @@ -311,7 +295,7 @@
        * @throws DbException if introspection failed.
        */
       private PropertyDescriptor[] propertyDescriptors(Class c) {
  -        // TODO Cache BeanInfo classes for better performance?
  +        // Introspector caches BeanInfo classes for better performance
           BeanInfo beanInfo = null;
           try {
               beanInfo = Introspector.getBeanInfo(c);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message