createdDate, createdBy, lastModifiedBy, lastModifiedDate in the JPA Override source code (too troublesome, see the updated method in the next article)

scene description

 公司项目升级为SpringBoot项目,新加入框架JPA,JPA自带的功能可以自动更新createdDate,createdBy,lastModifiedBy,lastModifiedDate这四个字段,但公司原有框架对应的字段为createDate,createId,updateId,updateDate,修改公司原有框架中的关于创建时间、更新时间的代码显然不科学,考虑过后决定override JPA中关于这几个字段的源码。

Rewrite JPA related code

spring-data-commons:1.13.0.RELEASE

The first step: annotation rewriting The original annotation and the rewritten annotation:
original annotationAdded annotation

@Retention(RetentionPolicy.RUNTIME)
@Target(value = { FIELD, METHOD, ANNOTATION_TYPE })
public @interface CreatedBy {
}

rewrite as

``` java
@Retention(RetentionPolicy.RUNTIME)
@Target(value = { FIELD, METHOD, ANNOTATION_TYPE })
public @interface CreatedBy {
}

Step 2: All files to be rewritten
All files to be overwritten

Replace all createDate, createId, updateId, updateDate and
you're done! Smooth docking with the original framework and database

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325521534&siteId=291194637