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

After executing the new sql, the object id is changed #794

Closed
Keafmd opened this issue Feb 16, 2023 · 4 comments
Closed

After executing the new sql, the object id is changed #794

Keafmd opened this issue Feb 16, 2023 · 4 comments

Comments

@Keafmd
Copy link

Keafmd commented Feb 16, 2023

After executing the new sql, the object id is changed.
Why? Does this happen occasionally?

@Keafmd
Copy link
Author

Keafmd commented Feb 16, 2023

ptListMapper.insertPtList(ptList);
//It needs to be reset, otherwise the ID is incorrect
ptList.setId(ptListId);
return ptList;

@Keafmd
Copy link
Author

Keafmd commented Feb 16, 2023

mybatis.spring.boot.starter.version>1.3.2

@harawata
Copy link
Member

Hello @Keafmd ,

It probably means that the value of id is auto-generated by the DB (i.e. AUTO_INCREMENT, IDENTITY, etc.) and MyBatis' useGeneratedKeys is enabled globally or for the statement.
https://github.com/mybatis/mybatis-3/wiki/FAQ#how-can-i-retrieve-the-value-of-an-auto-generated-key
https://mybatis.org/mybatis-3/configuration.html#settings

Note that MyBatis-Spring-Boot-Starter 1.3.2 is EOL (=no longer supported).
Please use a newer version.
http://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

@Keafmd
Copy link
Author

Keafmd commented Feb 16, 2023

As you said, I did make relevant configuration. Thank you!

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

3 participants