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/02 Report--
This article introduces the knowledge of "attention Analysis of the use of MyBatis General Mapper@Table annotations". 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!
The role of MyBatis generic Mapper@Table annotations using @ Table annotations
Generally, it works on the class name of the pojo entity class. After using this annotation, the attributes of the pojo class will have a mapping relationship with the corresponding table field (similar to the tag). For a simple mapping relationship, there is no need to write tags in the xml file for mapping.
Then you need to change resultMap to resultType in the xml file.
The return type is the entity class name.
Configure the database table name for the mapping.
The problem that should be paid attention to in the use of general mapper is that the entity needs to have relevant annotations.
@ table, @ Id @ Colunm
For example:
@ Table (name = "user_register") public class UserRegister {/ * it is important to note that the primary key must be marked with Id * / @ Id private Integer id; @ Column (name = "user_id") private String userId; / / omit other properties and getter setter methods}. Secondly, you need to pay attention to something.
MapperScan should be specified under the Mapper folder, otherwise there will be an inexplicable problem of two interfaces with the same name.
For example:
@ MapperScan (basePackages = {"com.jdjr.common.dao", "com.jdjr.admin.mapper"}) dependencies for specific use
The corresponding version can be used.
Tk.mybatis mapper-spring-boot-starter ${mapper.version.spring-boot} "Note Analysis for the use of MyBatis General Mapper@Table annotations" ends here. 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.