You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dg...@apache.org on 2004/08/23 04:07:36 UTC
cvs commit: jakarta-commons/dbutils/src/java/org/apache/commons/dbutils BeanProcessor.java
dgraham 2004/08/22 19:07:36
Modified: dbutils/src/java/org/apache/commons/dbutils
BeanProcessor.java
Log:
Call ResultSet.getTimestamp() if the bean property is a java.sql.Timestamp.
Oracle's getObject() implementation returns its own incompatible Timestamp class.
PR: 30749
Revision Changes Path
1.4 +12 -17 jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/BeanProcessor.java
Index: BeanProcessor.java
===================================================================
RCS file: /home/cvs/jakarta-commons/dbutils/src/java/org/apache/commons/dbutils/BeanProcessor.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BeanProcessor.java 14 Mar 2004 23:30:15 -0000 1.3
+++ BeanProcessor.java 23 Aug 2004 02:07:36 -0000 1.4
@@ -25,6 +25,7 @@
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -182,13 +183,9 @@
* @return An initialized object.
* @throws SQLException If a database error occurs
*/
- private Object createBean(
- ResultSet rs,
- Class type,
- PropertyDescriptor[] props,
- int[] columnToProperty,
- int cols)
- throws SQLException {
+ private Object createBean(ResultSet rs, Class type,
+ PropertyDescriptor[] props, int[] columnToProperty, int cols)
+ throws SQLException {
Object bean = this.newInstance(type);
@@ -221,11 +218,8 @@
* @param value The value to pass into the setter.
* @throws SQLException if an error occurs setting the property.
*/
- private void callSetter(
- Object target,
- PropertyDescriptor prop,
- Object value)
- throws SQLException {
+ private void callSetter(Object target, PropertyDescriptor prop, Object value)
+ throws SQLException {
Method setter = prop.getWriteMethod();
@@ -364,10 +358,8 @@
*
* @throws SQLException
*/
- protected int[] mapColumnsToProperties(
- ResultSetMetaData rsmd,
- PropertyDescriptor[] props)
- throws SQLException {
+ protected int[] mapColumnsToProperties(ResultSetMetaData rsmd,
+ PropertyDescriptor[] props) throws SQLException {
int cols = rsmd.getColumnCount();
int columnToProperty[] = new int[cols + 1];
@@ -447,7 +439,10 @@
} else if (propType.equals(Byte.TYPE) || propType.equals(Byte.class)) {
return new Byte(rs.getByte(index));
-
+
+ } else if (propType.equals(Timestamp.class)) {
+ return rs.getTimestamp(index);
+
} else {
return rs.getObject(index);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org