diff options
author | bolbic <bolbic@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-23 13:11:07 +0000 |
---|---|---|
committer | bolbic <bolbic@13f79535-47bb-0310-9956-ffa450edef68> | 2011-03-23 13:11:07 +0000 |
commit | 4c0321e552e05eeb4e6b80dbefc211414ebb68da (patch) | |
tree | ea207964fd769dc461be0e217eec2fd1d09a26a8 /das-java | |
parent | 7fc0b0758f779f9b628297ce167892b6f0451ed5 (diff) |
when mapping a result set to a data object, a mismatch between the value and property types may happen in some cases (e.g. booleans) and needs to be handled
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1084571 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'das-java')
-rw-r--r-- | das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java b/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java index 0e5fc48c0c..6e02b3dbbc 100644 --- a/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java +++ b/das-java/trunk/rdb/src/main/java/org/apache/tuscany/das/rdb/graphbuilder/impl/DataObjectMaker.java @@ -23,6 +23,7 @@ import java.util.Iterator; import java.util.Map; import org.apache.log4j.Logger; +import org.apache.tuscany.sdo.util.DataObjectUtil; import commonj.sdo.DataObject; import commonj.sdo.Property; @@ -101,8 +102,16 @@ public final class DataObjectMaker { } Object value = tableData.getColumnData(propertyName); - - obj.set(p, value); + try { + obj.set(p, value); + } catch (ClassCastException e) { + // a mismatch between the value and property types may happen in some cases + // e.g. when the property is a boolean but the database doesn't have a boolean data type + if (value != null) { + Object convertedValue = DataObjectUtil.getSetValue(p, value.toString()); + obj.set(p, convertedValue); + } + } } return obj; |