当前位置: 代码迷 >> Java相关 >> ,各位大神们,帮帮忙,多谢啦~ DataObjec ClassCastException
  详细解决方案

,各位大神们,帮帮忙,多谢啦~ DataObjec ClassCastException

热度:125   发布时间:2016-04-22 21:01:37.0
在线等,急,各位大神们,帮帮忙,谢谢啦~~~ DataObjec ClassCastException
在线等,急,各位大神们,帮帮忙,谢谢啦~~~ 
是DataObjec型的在set的时候报错   :dataObject.set(key, value);

set的字段:数据库中是number型,也试着改成integer,也报错
[14-8-8 10:49:10:243 CST] 00000031 SystemOut     O key=mainRemindTime3
[14-8-8 10:49:10:243 CST] 00000031 SystemOut     O value=0
[14-8-8 10:49:10:243 CST] 00000031 SystemOut     O 接口没有定义 xmlData 参数
[14-8-8 10:49:10:243 CST] 00000031 SystemOut     O set的key===mainRemindTime3set的value===0

异常信息:
 java.lang.ClassCastException: The value of type 'class java.lang.Integer' must be of type 'class java.math.BigInteger'
at org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateSingleDataStatic.validate(EStructuralFeatureImpl.java:2051)

java源码:
    
/** 1.1 if the value is still a HashMap, set the child BO */
if (value instanceof HashMap) {
DataObject childDataObject = dataObject.createDataObject(key);
// DataObject childDataObject =createBusinessObject(key);
dataObject.set(key, childDataObject);
createDataObject(childDataObject, (HashMap) value);
}
/** 1.2 if the value is a list, means that it is a list attribute */
else if (value instanceof List) {
List valueList = (List) value;
List valueList1 = dataObject.getList(key);
for (int i = 0; i < valueList.size(); i++) {
Object value1 = valueList.get(i);
/**
 * 1.2.1 if the value is still a HashMap, means that it is a
 * child BO
 */
if (value1 instanceof HashMap) {
DataObject childDataObject = dataObject
.createDataObject(key);
// DataObject childDataObject
// =createBusinessObject(key);
createDataObject(childDataObject, (HashMap) value1);
valueList1.add(childDataObject);
}
/**
 * 1.2.2 If the value is a simple datatype, set the
 * attribute directly
 */
else {
valueList1.add(value1);
}
}
}
/** 1.3 If the value is a simple datatype, set the attribute directly */
else {
//将工单字段拼成xml字符串,存入流程DataObject的xmlData中
try{
String xmlStr = dataObject.getString("xmlData");
if(xmlStr==null||xmlStr.equals("")){
xmlStr = "<?xml version=\"1.0\" encoding=\"gb2312\"?><fields>";
}else if(xmlStr.indexOf("</fields>")!=-1){
xmlStr = xmlStr.substring(0,xmlStr.indexOf("</fields>"));
}
xmlStr+="<field>"
+"<fieldName>"+key+"</fieldName>"
+"<fieldType>"+value.getClass().getName()+"</fieldType>"
+"<fieldValue>"+ (value.getClass().getName().equals("java.util.Date") ? (StaticMethod.date2String((Date)value)) : value)+"</fieldValue>" 
+"</field></fields>";
dataObject.set("xmlData", xmlStr);
}catch(java.lang.IllegalArgumentException err){
System.out.println("接口没有定义 xmlData 参数");
}catch(Exception e){
System.out.println("生成该字段的xml失败:"+e.getMessage());
}
System.out.println("set的key==="+key+"set的value==="+value);
dataObject.set(key, value);
}


------解决方案--------------------
换成bigInteger试试
  相关解决方案