用mybatis向mysql数据库插入一条数据后,然后查询出来。数据库里没有这条数据,但是程序通过查询语句却能查到这条数据
程序显示结果:
但是数据库就没能找到这条数据
大家讲道理2017-04-18 09:54:06
It’s not a cache at all, neither a database nor mybatis.
The database is easy to understand. The data you have not committed can only be found in your current transaction, and cannot be found by other clients. If it is found, wouldn't it be dirty reading?
The cache of mybatis is very simple. By default, insert, delete, and update will clear the cache. Only when selecting, will things be placed in the cache.
So the answer is obvious, it’s the problem of turning off auto commit and not committing the update operation to the database, so you can only check it on your own, but you can’t find it if you open a client
高洛峰2017-04-18 09:54:06
Your picture:
Could it be the reason for your affairs? Because you query it immediately after inserting it, but the transaction has not been submitted yet?
迷茫2017-04-18 09:54:06
The program may use a caching mechanism. The data you inserted may be in the cache and not yet in the database. Search the database cache on Baidu
ringa_lee2017-04-18 09:54:06
Proper business issues. Brother, you can see it after the transaction is submitted.