In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article Xiaobian introduces in detail "mybatis dynamic stitching how to achieve conditional insertion", detailed content, clear steps, details handled properly, hope that this article "mybatis dynamic stitching how to achieve conditional insertion" article can help you solve doubts, the following follow the editor's ideas slowly in-depth, together to learn new knowledge bar.
Conditional insertion of dynamic stitching implementation has recently encountered a very real problem when working on a project.
That is, according to different scenarios, and then achieve conditional insertion, to put it bluntly, it is to insert data when the column has data, and automatically ignore the column when there is no data.
In fact, these are involved in mybatis's api, but I haven't seen it well before, and I didn't take a serious look at this piece of content until I used it recently.
Insert into base_department_staff status, group_id, staff_code, realname, create_time, phone, is_temporary email, user_id Sex, # {param.status}, # {param.groupId}, # {param.staffCode}, # {param.realname}, # {param.phone}, # {param.temporary} # {param.email} # {param.userId}, # {param.sex}
I believe that there is no need to say much about the trim in this, and it is often used to go to and from spaces. There are three attributes in this trim tag, prefix this indicates that you want to concatenate the prefix of sql, suffix this indicates the suffix of dynamic sql, and suffixOverrides this will help me remove the last extra comma.
Mybatis insert statement mybatis insert statement is usually written like this
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.
Always thought that useGeneratedKeys= "true" is to add the primary key to the mysql database, but in fact, after inserting the statement, the id is assigned to the entity bean, even after using insert, you can get the value using bean.getId (), if false,bean.getId () = null.
Whether true or false, the primary key is automatically generated by the data inserted by the database (provided that the primary key is automatically grown).
Read here, this "mybatis dynamic splicing how to achieve conditional insertion" article has been introduced, want to master the knowledge of this article also need to practice and use in order to understand, if you want to know more related articles, welcome to pay attention to 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.