java - mybatis 插入一条数据时,数据库没能找到这条数据,但是程序却可以查询出这条数据
PHP中文网
PHP中文网 2017-04-18 09:52:06
0
6
438

用mybatis向mysql数据库插入一条数据后,然后查询出来。数据库里没有这条数据,但是程序通过查询语句却能查到这条数据

程序显示结果:

但是数据库就没能找到这条数据

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(6)
大家讲道理

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

小葫芦

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?

迷茫

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

黄舟

I think it’s because there’s no commit in

阿神

It can only mean that the transaction was not submitted

左手右手慢动作

Proper business issues. Brother, you can see it after the transaction is submitted.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!