In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Mybatis how to get the id of the latest insert data, the article is very detailed, has a certain reference value, interested friends must read it!
The original id method to get the latest inserted data
Read the insert data of the last item, but this will cause concurrency errors if two pieces of data are inserted at the same time.
SELECT * FROM admin_users where 1 # 1 ORDER BY id desc LIMIT 1select MAX (id) from admin_users uses useGeneratedKeys
The value range of useGeneratedKeys is true | the default value of false is false.
Meaning: sets whether to use the getGenereatedKeys method of JDBC to get the primary key and assign it to the domain model property of the keyProperty setting.
Just take the id after the registration is completed.
IMS_BS_BOOK_COPY PRICE,ENTITY_ID,CODE,ADD_TIME,STATUS,REASON,GRID_CODE,STALL_CODE,CASE_CODE,ORDER_CODE # {PRICE}, # {ENTITY_ID}, # {CODE}, # {ADD_TIME}, # {STATUS}, # {REASON}, # {GRID_CODE}, # {STALL_CODE}, # {CASE_CODE} # {ORDER_CODE} insert into () values () query the latest data according to time the first xml configuration based on the latest insertion time SELECT * from table name where createtime= (select max (createtime) from table name where field name = # {parameter name JdbcType=VARCHAR}) the second type of xml configuration is based on ownumselect id= "selectLast" resultMap= "BaseResultMap" parameterType= "java.lang.String" > select t. From table name where field name = # {parameter name, jdbcType=VARCHAR} order by createtime desc) t where rownum=1 is all the content of the article "how to get the id of the latest inserted data" Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.