Rumah >pangkalan data >tutorial mysql >ibatis sqlserver 存储过程
ibatis调用sqlserver存储过程: order.xml ?xml version=1.0 encoding=UTF-8?!DOCTYPE sqlMapPUBLIC -//iBATIS.com//DTD SQL Map 2.0//ENhttp://www.ibatis.com/dtd/sql-map-2.dtdsqlMaptypeAlias alias=order type=com.xinrui.pojo.Order /parameterMap id=
ibatis调用sqlserver存储过程:
order.xml
<?xml version="1.0" encoding="UTF-8"?> <sqlmap> <typealias alias="order" type="com.xinrui.pojo.Order"></typealias> <parametermap id="ParaMap_order" class="order"> <parameter property="pid" mode="IN" javatype="java.lang.Integer" jdbctype="int"></parameter> <parameter property="price" mode="IN" javatype="java.lang.Double" jdbctype="varchar"></parameter> <parameter property="nums" mode="IN" javatype="java.lang.Integer" jdbctype="int"></parameter> <parameter property="unit" mode="IN" javatype="java.lang.String" jdbctype="varchar"></parameter> <parameter property="notes" mode="IN" javatype="java.lang.String" jdbctype="varchar"></parameter> <parameter property="proid" mode="IN" javatype="java.lang.Integer" jdbctype="int"></parameter> </parametermap> <procedure id="addOrders" parametermap="ParaMap_order"> </procedure> </sqlmap>
public String submit_orders() { HttpServletRequest request = ServletActionContext.getRequest(); Order o = new Order(); o.setPid(10000); o.setNotes("aaaaaaaaaaaaaaa"); o.setNums(121); o.setPrice(123.123); o.setUnit("bbbbbbbbbbbbbb"); o.setProid(10000); orderService.addOrders(o); return new Constant().SUBMITING; }
备注:
1.order.xml中,中的?与parameterMap中的parameter顺序相同;
2.javaType为pojo中的变量属性,jdbcType为数据库中对应字段属性;