0 0

ibatis设置nullvalue怎么不起作用?10

引用

<insert id="insertCategory" parameterClass="Category">
<![CDATA[
insert into dg_category
(id, parentId, title, alias, name, position)
values
(#id#, #parentId:VARCHAR:''#, #title#, #alias#, #name#, #position#)
]]>
</insert>


当parentId为null时就报错,写成parameterMap形式也是一样的.搞了一天,头疼死了

--- Cause: com.mysql.jdbc.exceptions.MySQLIntegrityConstraintViolationException: Column 'parentId' cannot be null

2008年6月17日 16:29

1个答案 按时间排序 按投票排序

0 0

采纳的答案

<insert id="insertCategory" parameterClass="Category">
<![CDATA[
insert into dg_category
(id, parentId, title, alias, name, position)
values
<dynamic>
<isNotNull property="parentId">
(#id#, #parentId:VARCHAR:''#, #title#, #alias#, #name#, #position#)
</isNotNull>
<isNull property="parentId">
(#id#, null, #title#, #alias#, #name#, #position#)
</isNull>
</dynamic>
]]>
</insert>

实在搞不定,用一个折中的办法.

2008年6月17日 17:38

相关推荐

Global site tag (gtag.js) - Google Analytics