Skip to content
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

sqlite Long type value convert bug #3242

Closed
sailingsky opened this issue Sep 21, 2024 · 1 comment
Closed

sqlite Long type value convert bug #3242

sailingsky opened this issue Sep 21, 2024 · 1 comment

Comments

@sailingsky
Copy link

MyBatis version

3.5.14

Database vendor and version

sqlite 3.45.0
sqlite-jdbc 3.46.1.0

Test case or example project

example project: https://github.com/sailingsky/sqlite-test.git

Steps to reproduce

there are two records in table test:

id       name
22	test22
850361281191579648	 tt

run post request: https://localhost:8083/test/maps

Expected result

[{"name":"test22","id":22},{"name":" tt","id":850361281191579648}]

Actual result

[{"name":"test22","id":22},{"name":" tt","id":1881903104}]

the second record's id value is wrong. the related issue had been submit to sqlite-jdbc: xerial/sqlite-jdbc#1177 . FYI

@harawata
Copy link
Member

Hello @sailingsky ,

You have already found the real cause, it seems.
When you are using java.util.Map as the result type, MyBatis calls ResultSet#getColumnClassName() to determine the Java type of the column.
And the driver determines the result based on the column value of the first row which clearly is a flawed logic and causes the problem you are experiencing.

https://github.com/xerial/sqlite-jdbc/blob/02bac1a4a5d28a08334d197d3a3bb246fab9cb05/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java#L583-L588

I'll watch the issue xerial/sqlite-jdbc#1177 .
Until it gets fixed, you may have to use a custom class (POJO) instead of java.util.Map.

I am going to close this as it is a driver issue and there is nothing to fix in MyBatis side.

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