Claus Ibsen created CAMEL-26145:
-----------------------------------

             Summary: camel-mybatis - with InOut, Insert/Update/Delete set the 
body to null, and an Insert with no body stores a row of nulls
                 Key: CAMEL-26145
                 URL: https://issues.apache.org/jira/browse/CAMEL-26145
             Project: Camel
          Issue Type: Bug
          Components: camel-mybatis
            Reporter: Claus Ibsen
             Fix For: 4.24.0


Found while adding the catalog body types of mybatis and mybatis-bean 
(CAMEL-24961, PR #28393).

h4. 1. With InOut, Insert, Update and Delete set the body to null

{{MyBatisProducer.doProcessResult}} (main 2a465aa4814c, line 225) uses 
{{exchange.getOut()}} for an InOut exchange (line 230) and copies the in body 
only when {{outputHeader}} is set (lines 233-236). For Insert, InsertList, 
Update, UpdateList, Delete and DeleteList the result goes into the 
{{CamelMyBatisResult}} header only (line 271), so the body after the call is 
null instead of the body sent. With InOnly the body is kept. Checked on 
4.24.0-SNAPSHOT with an embedded H2: 
{{requestBody("mybatis:insertAccount?statementType=Insert", account)}} returns 
null.

Proposed: copy the in body to the out message for the statement types that do 
not set the body, as InOnly does.

h4. 2. An Insert with no body stores a row of nulls without an error

{{MyBatisProducer.doInsert}} (main 2a465aa4814c, line 126) calls 
{{session.insert(statement)}} without a parameter when the body is null (line 
139), so a statement with parameter placeholders inserts a row where every 
column is NULL, with no error. Reading that row back with SelectList gives a 
null element (MyBatis {{returnInstanceForEmptyRow}} default), so it is easy to 
miss. Checked on 4.24.0-SNAPSHOT with an embedded H2.

Proposed: fail with a clear message when the body is null and the mapped 
statement has parameters.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to