In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge of "how to cancel the query cache by mybatis". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Project needs, requires the use of annotated development, due to the use of ORACLE, but also need to bulk insert the original sql is as follows, and later reported an error: violation of unique constraints
@ Insert ("\ n" + "insert all\ n" + "\ n" + "into TD_SYS_USER_ROLE (DATA_ID, USER_ID, ROLE_ID, CREATE_TIME, CREATE_USER, DATA_STATUS)\ n" + "values (\ n" + "TD_SYS_USER_ROLE$SEQ.nextval) \ n "+" # {userRole.userId,jdbcType=VARCHAR},\ n "+" # {userRole.roleId,jdbcType=VARCHAR},\ n "+" # {userRole.createTime,jdbcType=DATE},\ n "+" # {userRole.createUser,jdbcType=VARCHAR},\ n "+" # {userRole.dataStatus JdbcType=CHAR}\ n "+")\ n "+"\ n "+" select 1 from dual "+") void add (@ Param ("tdSysUserRoles") List tdSysUserRoles)
Later, it was found that when you insert a batch in this way, the inserted DATA_ID is all the same, so you want to extract the DATA_ID acquisition method and change it to the following:
@ Insert ("\ n" + "insert all\ n" + "\ n" + "into TD_SYS_USER_ROLE (DATA_ID, USER_ID, ROLE_ID, CREATE_TIME, CREATE_USER, DATA_STATUS)\ n" + "values (\ n" + "# {userRole.dataId,jdbcType=VARCHAR}) \ n "+" # {userRole.userId,jdbcType=VARCHAR},\ n "+" # {userRole.roleId,jdbcType=VARCHAR},\ n "+" # {userRole.createTime,jdbcType=DATE},\ n "+" # {userRole.createUser,jdbcType=VARCHAR},\ n "+" # {userRole.dataStatus JdbcType=CHAR}\ n "+")\ n "+"\ n "+" select 1 from dual "+") void add (@ Param ("tdSysUserRoles") List tdSysUserRoles) @ Select ("select TD_SYS_USER_ROLE$SEQ.nextval from dual") String getId ()
It is found that the same error will still occur. After thinking about it, it is estimated that it is the cache problem of mybaits. Later, the following changes have been made
@ Select ("select TD_SYS_USER_ROLE$SEQ.nextval from dual") @ Options (useCache = false,flushCache = Options.FlushCachePolicy.TRUE) String getId ()
Perfect solution
This is the end of the content of "how mybatis cancels query caching". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.