I have a Mybatis select that uses two parameters that are collections. The first collection passes in multiple Integers, the second collection, which is sometimes skipped because of a surrounding if, acts as if only the first element is set. the resulting statement and parameters from the log are: DEBUG 2025-01-27 20:56:27,466 ViewDb.ListWithCvs ==> Preparing: SELECT b.id, b.decoderid, a.dccAddress, a.roadName AS roadName, a.roadNumber AS roadNumber, cvNumber AS cvNumber, cvValue AS cvValue FROM ( SELECT * FROM cvvalues WHERE decoderid in (7, 8, 9) AND cvNumber IN ( ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) ) AS b INNER JOIN decoder a ON a.id = b.decoderId ORDER BY b.decoderid, cvNumber DEBUG 2025-01-27 20:56:27,470 ViewDb.ListWithCvs ==> Parameters: 2(String), 3(String), 4(String), 5(String), 6(String), 7(String), 8(String), 9(String), 0.255.285(String), 0.255.286(String), 0.255.287(String) TRACE 2025-01-27 20:56:27,475 ViewDb.ListWithCvs <== Columns: ID, DECODERID, DCCADDRESS, ROADNAME, ROADNUMBER, CVNUMBER, CVVALUE TRACE 2025-01-27 20:56:27,476 ViewDb.ListWithCvs <== Row: 6639, 7, 4390, PRR, 4390, 2, 2 TRACE 2025-01-27 20:56:27,479 ViewDb.ListWithCvs <== Row: 6831, 8, 5432, PRR, 5432, 2, 2 TRACE 2025-01-27 20:56:27,480 ViewDb.ListWithCvs <== Row: 6928, 9, 5754, Pennsylvania, 5754, 2, 2 DEBUG 2025-01-27 20:56:27,480 ViewDb.ListWithCvs <== Total: 3

When used with these same paremeters in DbVisualizer, it retrieves 571 rows (which Mybatis would then roll up into 3 objects). If I use a fixed grouping with literal values for these parameters, all the expected rows are returned and rolled up together. Here is the the Select and the ResultMap:

Comment From: harawata

Hello @swalton00 ,

Please create a small repro project with assertions and share it on your GitHub repository. Here are some project templates and examples: https://github.com/harawata/mybatis-issues

And please try to reduce the number of tables/columns/classes in the repro project. Here is a good guide for creating a repro: https://www.sscce.org/

Comment From: swalton00

I'm closing this as the problem (after a gread deal of research) was that I was not correctly trimming blanks from the parameters I was passing. Every parameter (except the first) had a single blank at the front. This caused those parameters to not match. And the extra blank was very difficult to see. Only after I completed a repro project and had it succeed was it obvious that the problem was in my code.