【急】IBatis中update时提示
java.lang.NullPointerException?
sqlmap:
<update id="updateByMapSQL" parameterClass="java.util.Map">
update MEAT_OUT_INFO_BASE set SEND_STATE ='0' where TRAN_ID ='1001'
<dynamic prepend="set">
<isNotEmpty prepend="," property="butcherFacId">
<![CDATA[ BUTCHER_FAC_ID = #butcherFacId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="butcherFacName">
<![CDATA[ BUTCHER_FAC_NAME = #butcherFacName# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="sellerId">
<![CDATA[ SELLER_ID = #sellerId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="sellerName">
<![CDATA[ SELLER_NAME = #sellerName# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="buyerId">
<![CDATA[ BUYER_ID = #buyerId# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="buyerName">
<![CDATA[ BUYER_NAME = #buyerName# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="dest">
<![CDATA[ DEST = #dest# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="sendState">
<![CDATA[ SEND_STATE = #sendState# ]]>
</isNotEmpty>
<isNotEmpty prepend="," property="sendFailReson">
<![CDATA[ SEND_FAIL_RESON = #sendFailReson# ]]>
</isNotEmpty>
</dynamic>
<dynamic prepend="where">
<isNotEmpty prepend="AND" property="tranId">
<![CDATA[ TRAN_ID = #tranId# ]]>
</isNotEmpty>
</dynamic>
</update>
dao.impl:
public int update(String[] pK, String[] properties, Object[] propertyValues) throws Exception {
// 更新数据库
Map<String, Object> map = new HashMap<String, Object>();
for (int i = 0; i < properties.length; i++) {
map.put(properties[i], propertyValues[i]);
}
map.put(pK[0], pK[1]);
return masterSqlMapClientTemplate.update(clazz.getName() + POSTFIX_UPDATEBYMAP, map);
}
调用:
public static void updateState(String tranId) {
System.out.println("更新交易信息");
/*
* MeatOutInfoBase model = new MeatOutInfoBase();
* model.setTranId(tranId); model.setSendState("1");
* model.setSendFailReson("失败了"); MeatOutInfoBaseDaoImpl dao = new
* MeatOutInfoBaseDaoImpl(); int result = dao.updateState(model);
*/
MeatOutInfoBaseDao dao = (MeatOutInfoBaseDao) context
.getBean("meatOutInfoBaseDao");
String[] pK = { "tranId", tranId };
String[] properties = { "sendState", "sendFailReson" };
String[] propertyValues = { "0", "数据读取超时" };
int result = 0;
try {
result = dao.update(pK, properties, propertyValues);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("更新返回值:" + result);
}
报错:
java.lang.
NullPointerException at com.sunraw.rock.dao.impl.GenericDaoImpl.update(GenericDaoImpl.java:339)
at com.sunraw.test.MeatOutInfoBaseTest.updateState(MeatOutInfoBaseTest.java:88)
更新交易信息
更新返回值:0
at com.sunraw.test.MeatOutInfoBaseTest.main(MeatOutInfoBaseTest.java:25)