commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Dudgeon <...@informaticsmatters.com>
Subject [BeanUtils, SQL] Controlling mappings of sql to java types
Date Tue, 26 Oct 2004 10:46:03 GMT
Hi,
I've been using ResultSetDynaClass and RowSetDynaClass for a bit, and 
find these very handy. I've also looked ino the things in the SQL 
project as a lightweight. persistence layer. Both of these look very 
useful for my purpose as I need to obtain access to the ResultSet on a 
row-by-row basis.

I'd like to be able to control the Java type of the values that are 
obtained from these DynaBeans. From what I can gather there is a default 
mapping of the sql type to a Java class, so that when you call
Object o = dynaBean.get("myProperty");
the class of the object returned is predetermined based, presumably, on 
some default mapping from the SQL type to the Java type.

Is there any way of changing this on a column-by-column basis. e.g. I 
might have two number columns in my ResultSet, and I want one to be a 
Float, the other a Double so that I could say

Double d = (Double)dynaBean.get("col1");
Float f = (Float)dynaBean.get("col2");

Thanks

Tim

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


Mime
View raw message