当我使用ibatis2mybatis迁移此sqlMap
时<procedure id="correctPcsInvoiceInCn"
parameterClass="java.util.Map" >
exec correctPcsInvoice
<isNotNull property="insertingPersonId" >#insertingPersonId# </isNotNull> <isNull property="insertingPersonId" > null </isNull>
<isNotNull prepend="," property="contractServicePerfID" >#contractServicePerfID# </isNotNull> <isNull prepend="," property="contractServicePerfID" > null </isNull>
<isNotNull prepend="," property="chemotherapyInvoiceID" >#chemotherapyInvoiceID# </isNotNull> <isNull prepend="," property="chemotherapyInvoiceID" > null </isNull>
<isNotNull prepend="," property="tariff" >#tariff# </isNotNull> <isNull prepend="," property="tariff" > null </isNull>
<isNotNull prepend="," property="medicalProductDetailsID" >#medicalProductDetailsID# </isNotNull> <isNull prepend="," property="medicalProductDetailsID" > null </isNull>
<isNotNull prepend="," property="drugPackageUnitsCount" >#drugPackageUnitsCount# </isNotNull> <isNull prepend="," property="drugPackageUnitsCount" > null </isNull>
<isNotNull prepend="," property="drugPackagePrice" >#drugPackagePrice# </isNotNull> <isNull prepend="," property="drugPackagePrice" > null </isNull>
<isNotNull prepend="," property="invoiceNumber" >#invoiceNumber# </isNotNull> <isNull prepend="," property="invoiceNumber" > null </isNull>
<isNotNull prepend="," property="positionInInvoice" >#positionInInvoice# </isNotNull> <isNull prepend="," property="positionInInvoice" > null </isNull>
<isNotNull prepend="," property="taxPayerID" >#taxPayerID# </isNotNull> <isNull prepend="," property="taxPayerID" > null </isNull>
</procedure>
我得到了
<update id="correctPcsInvoiceInCn" parameterType="java.util.Map" statementType="CALLABLE">
exec correctPcsInvoice
<if test="insertingPersonId != null">#{insertingPersonId} </if> <if test="insertingPersonId == null"> null </if>
<if test="contractServicePerfID != null">,#{contractServicePerfID} </if> <if test="contractServicePerfID == null">, null </if>
<if test="chemotherapyInvoiceID != null">,#{chemotherapyInvoiceID} </if> <if test="chemotherapyInvoiceID == null">, null </if>
<if test="tariff != null">,#{tariff} </if> <if test="tariff == null">, null </if>
<if test="medicalProductDetailsID != null">,#{medicalProductDetailsID} </if> <if test="medicalProductDetailsID == null">, null </if>
<if test="drugPackageUnitsCount != null">,#{drugPackageUnitsCount} </if> <if test="drugPackageUnitsCount == null">, null </if>
<if test="drugPackagePrice != null">,#{drugPackagePrice} </if> <if test="drugPackagePrice == null">, null </if>
<if test="invoiceNumber != null">,#{invoiceNumber} </if> <if test="invoiceNumber == null">, null </if>
<if test="positionInInvoice != null">,#{positionInInvoice} </if> <if test="positionInInvoice == null">, null </if>
<if test="taxPayerID != null">,#{taxPayerID} </if> <if test="taxPayerID == null">, null </if>
</update>
ibatis2mybatis生成这个,但我不知道它是好还是不好? any1可以验证这部分代码吗?如果可能的话,改成好的。
答案 0 :(得分:0)
在myBatis
中使用bean代替map更好public InvoiceBean {
private Integer insertingPersonId;
...
//getters, setters
}
并像这样使用它:
<update id="correctPcsInvoiceInCn" parameterType="your.packadge.InvoiceBean" statementType="CALLABLE">
exec correctPcsInvoice #{insertingPersonId, jdbcType=NUMERIC}, ...other parameters
</update>
将jdbcType添加到参数允许myBatis为其设置正确的空值。