Created
January 28, 2019 07:53
-
-
Save gcdd1993/f0030f9f2427bc825d9d43f372dcb123 to your computer and use it in GitHub Desktop.
Hibernate乐观锁抽象类
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.maxtropy.imep.entity.base; | |
import lombok.Data; | |
import org.hibernate.annotations.CreationTimestamp; | |
import org.hibernate.annotations.UpdateTimestamp; | |
import javax.persistence.Column; | |
import javax.persistence.MappedSuperclass; | |
import javax.persistence.Version; | |
import java.sql.Timestamp; | |
/** | |
* 数据库基本时间结构 | |
* 包含创建时间与更新时间 | |
* 创建时间不允许更新 | |
* 更新时间作为乐观锁 | |
* Created by IntelliJ IDEA. | |
* User: gaochen | |
* Date: 2018/12/5 | |
*/ | |
@Data | |
@MappedSuperclass | |
public class TimeBase { | |
@CreationTimestamp | |
@Column(nullable = false, updatable = false) | |
protected Timestamp createTime; | |
@Version | |
@UpdateTimestamp | |
@Column(nullable = false) | |
protected Timestamp updateTime; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment