开发者

iBatis generates only 6 parameters (all null), other time generates 9 parameters

I have a good insert statement which has 9 parameters, but for some reason iBatis generates only 6 for a particular object. For all other it generates 9, as it should.

Could it be the fact that all params are NULL ?

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

OK:

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

NOK:

Parameters: [null, null, null, null, null, null]

And the erro开发者_Python百科r is as you expected:

Missing IN or OUT parameters at index 7

INSERT 17 COLUMNS INTO SOME_TABLE VALUES (
        #id#,
        #someObj.id#,
        #someOtherObj.id#,
        #aProperty#,
        #anotherProperty#,
        null,
        #yetAnotherProperty#,
        null,
        null,
        null,
        null,
        null,
        #prop1#,
        #prop2#,
        #prop3#,
        null,
        null)

someObj and someOtherObj are NULL. Also my app uses cglib for lazy loading, so some enhances might be present, don't know if it affects something.


You could do this:

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜