How to use mybatis-plus compound primary key
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!