Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use mybatis-plus compound primary key

Shulou Source: shulou.com Published: 2022-06-01 07:14:09 10月04日 Update

Editor to share with you how to use the mybatis-plus compound primary key. I hope you will get something after reading this article. Let's discuss it together.

1.mybatis-plus version

Com.github.jeffreyning mybatisplus-plus 1.5.1-RELEASE com.baomidou mybatis-plus-boot-starter 3.1.0 com.baomidou mybatis-plus-generator 3.1.0

two。 Entity class

@ TableName ("etl_job") public class Job implements Serializable {private static final long serialVersionUID=1L; @ MppMultiId / / compound primary key private String etlSystem; @ MppMultiId / / compound primary key private String etlJob;}

3.Mapper class and mapper.xml

Public interface JobMapper extends MppBaseMapper {}

4.Server and ServiceImpl

Public interface JobService extends IMppService {} @ Servicepublic class JobServiceImpl extends MppServiceImpl implements JobService {}

5. The next step is to formally apply the operations related to the compound primary key.

JobService.saveOrUpdateByMultiId (job)

6. To launch the compound primary key, remember to add @ EnableMPP to the startup class.

After reading this article, I believe you have a certain understanding of "how to use the mybatis-plus compound primary key". If you want to know more about it, welcome to follow the industry information channel. Thank you for your reading!

Tags: Article next finished entity that is more version knowledge industry information information channel channel application Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Apple Linux MySQL Shulou Information