Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of excluding unnecessary Fields in mybatis plus Associated Database

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Most people do not understand the knowledge points of this article "the method of excluding unnecessary fields in mybatis plus related database", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "mybatis plus related database excluding unnecessary fields" article.

Associated database excluding unnecessary fields java comes with / * virtual binding process current approver corresponding table field of transient * / private transient String status; declares that this field is static / * virtual binding process current approver corresponding table field * / private static String status Declare through annotations that the field is not a field in a database table / * Virtual binding process current approver corresponding table field * / @ TableField (exist = false) private String status

Which business scenario is used in which way?

If you want to support serialization without associating database fields, use @ TableField

If you just don't want to associate the database, you can use all three

In the project, since the data must be serialized and deserialized when exporting excel, it is true that using transient can exclude non-database fields, but it will also result in null when data is exported, so it is best to use @ @ TableField for this scenario.

Exclude custom fields and do not query the reason for the demand

Because the database table is designed as a group table

One is the parameter table under the corresponding group.

When querying the data, you want to look up the data pages under the corresponding group while querying the group table.

Therefore, a corresponding parameter is added under the group entity class to accept the corresponding group data.

Error screenshot

Error analysis

According to the query statement,

All fields are checked out by default in the conditional query.

However, an error was reported because the custom field does not exist in the database.

Try

The biggest problem here is how to exclude the custom fields and search the Internet.

Finally, I found it in the official documents of Mybatis-plus.

@ TableFiled has an exist property that defines whether the field is a database table field.

So add the attribute

Rerun

The above is about the content of this article on "the method of excluding unnecessary fields in mybatis plus related database". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report