Skip to content

Select with a ArrayList<String> as argument only the first parameter seems to be passed. #906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
swalton00 opened this issue Jan 28, 2025 · 1 comment

Comments

@swalton00
Copy link

The interface (written in Groovy):

interface ViewDb {
List listDecodersByRosterID(List array)
List ListWithCvs(Vector decoderID, List cvs, Boolean listAll)
}

The mapper:

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 #{item} AND cvNumber IN ('1', '2', '3', '4', '5' , '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19') #{item,jdbcType=VARCHAR} ) AS b INNER JOIN decoder a ON a.id = b.decoderId ORDER BY b.decoderid, cvNumber

With arg1 null and the second parameter is false, I get the collection "CvValues" populated as expected. When I pass in arg0 and arg1, the log shows the expected values, but the results act as if only the first value in the arg1 array was used:
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
If I select the same query with dbVisualizer with the same parameters I get 257 (which Mybatis would roll up into 3 rows with the values in cvValues array.

I have tried many times to get this to work but no matter how I phrase the query, I can't get Mybatis to enter all the values unless I use literals. Is this a bug?

@jeffgbutler
Copy link
Member

Duplicate of mybatis/mybatis-3#3402

@jeffgbutler jeffgbutler marked this as a duplicate of mybatis/mybatis-3#3402 Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants