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

How Mybatisplus uses @ EnableKeyGen to start the custom primary key padding function in the startup class

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces how Mybatisplus uses @ EnableKeyGen to start the primary key to customize the primary key filling function in the startup class, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.

Use @ EnableKeyGen to start the custom primary key fill function in the startup class. Note that if you implement IKeyGenerator, it will conflict with @ EnableKeyGen.

@ SpringBootApplication@EnableMPP@EnableKeyGenpublic class PlusDemoApplication {public static void main (String [] args) {SpringApplication.run (PlusDemoApplication.class, args);}}

Set @ KeySequence on the entity class to automatically populate the primary key field with complex calculated values when inserting

@ KeySequence ("select lpad (max (seqno) + 3Magne10) from test") @ TableName (value = "test") public class TestEntity {@ TableId (value = "id", type=IdType.INPUT) private Integer id Thank you for reading this article carefully. I hope the article "Mybatisplus how to use @ EnableKeyGen to start custom primary key filling function in startup class" shared by the editor is helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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

Servers

Wechat

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

12
Report