ibatis 调用存储过程报
java.lang.NullPointerException错,50分相谢!!
(1)我的xml:
<parameterMap id= "invoiceInsertMap " class= "java.util.map " >
<parameter property= "invoicestart " jdbcType= "NUMBER " javaType= "java.lang.Long " mode= "IN "/>
<parameter property= "totalnum " jdbcType= "NUMBER " javaType= "java.lang.Integer " mode= "IN "/>
<parameter property= "invoicebookid " jdbcType= "NUMBER " javaType= "java.lang.Integer " mode= "IN "/>
</parameterMap>
<procedure id= "invoiceInsert " parameterMap= "invoiceInsertMap " >
{call invoiceInsert (?,?,?)}
</procedure>
(2)invoiceInsert 为数据库中存储过程,代码无误
(3)对外调用的接口:
public int invoiceInsert(InvoiceBook invoicebook) {
HashMap paramMap = new HashMap();
paramMap.put( "invoicestart ", invoicebook.getInvoicestart());
paramMap.put( "totalnum ", invoicebook.getInvoicedicid());
paramMap.put( "invoicebookid ", invoicebook.getInvoicebookid());
return invoiceDao.invoiceInsert(paramMap);
}
(4)invoiceDao 对xml配置中调用:
public int invoiceInsert(HashMap paramMap) {
int i=0;
try{
daoManager.startTransaction();
i=((Integer)queryForObject( "invoiceInsert ",paramMap)).intValue();
daoManager.commitTransaction();
}catch(Exception e ){
e.printStackTrace();
}
return i;
}
控制台打印的结果
{call invoiceInsert (?,?,?)}
[100000000, 20, 1]
Types: [java.lang.Long, java.lang.Integer, java.lang.Integer]
java.lang.
NullPointerException 如果可以给个实例,也万分感谢!!!
------解决方案--------------------paramMap.put( "invoicestart ", invoicebook.getInvoicestart());
paramMap.put( "totalnum ", invoicebook.getInvoicedicid());
paramMap.put( "invoicebookid ", invoicebook.getInvoicebookid());
你Debug一下看看这里面的参数是不是都有值啊?
------解决方案--------------------帮定~
------解决方案--------------------NullPointerException是最常见的一种错误了。
我对ibatis、存储过程都不是太了解,对你的程序也了解。
不过我推测是这一句报的nullpointer:i=((Integer)queryForObject( "invoiceInsert ",paramMap)).intValue();
queryForObject返回了null,你debug一下看看
------解决方案--------------------看日志