1


我有一个很好的插入语句,它有 9 个参数,但由于某种原因 iBatis 只为特定对象生成 6 个。对于所有其他,它应该生成 9。
难道是所有参数都是 NULL 的事实吗?

?,?,?,?,?,null,?,null,null,null,null,null,?,?,?,null,null

好的:

参数:[[B@132b63e, [B@5ac911, [B@468066, xxxxxxxxxxxxxxxx, null, null, 0, 0, 0]

挪威克朗:

参数:[空,空,空,空,空,空]

错误如您所料:

索引 7 处缺少 IN 或 OUT 参数

将 17 列插入 SOME_TABLE 值(
        #ID#,
        #someObj.id#,
        #someOtherObj.id#,
        #aProperty#,
        #anotherProperty#,
        空值,
        #yetAnotherProperty#,
        空值,
        空值,
        空值,
        空值,
        空值,
        #prop1#,
        #prop2#,
        #prop3#,
        空值,
        空值)

someObj 和 someOtherObj 为 NULL。此外,我的应用程序使用 cglib 进行延迟加载,因此可能存在一些增强功能,不知道它是否会影响某些东西。

4

1 回答 1

1

你可以这样做:

INSERT 17 COLUMNS INTO SOME_TABLE VALUES (
        #id#,
        <isNotNull property="someObj">
            #someObj.id#,
        </isNotNull>
        <isNull property="someObj">
            NULL,
        </isNull>
        <isNotNull property="someOtherObj">
            #someOtherObj.id#,
        </isNotNull>
        <isNull property="someObj">
            NULL,
        </isNull>
        #aProperty#,
        #anotherProperty#,
        null,
        #yetAnotherProperty#,
        null,
        null,
        null,
        null,
        null,
        #prop1#,
        #prop2#,
        #prop3#,
        null,
        null)
于 2011-08-24T07:59:41.480 回答