【01-14】hibernate时间生成


package rugal.sample.core.entity; import java.util.Date;
import java.util.UUID; import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType; import org.hibernate.annotations.GenericGenerator; @Entity
@Table(name = "tbl_time_test")
public class CreateTimeTest { @Id
@GenericGenerator(name = "UUIDGENERATE", strategy = "uuid2")
@GeneratedValue(generator = "UUIDGENERATE")
@Column(name = "id")
private UUID id; /**
* 指定insert时自动插入
*/
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "create_time", updatable = false)
@org.hibernate.annotations.CreationTimestamp
private Date createTime; /**
* 指定update时自动更新
*/
@Column(name = "update_time")
@org.hibernate.annotations.UpdateTimestamp
@Temporal(TemporalType.TIMESTAMP)
private Date updateTime; public UUID getId() {
return id;
} public void setId(UUID id) {
this.id = id;
} public Date getCreateTime() {
return createTime;
} public void setCreateTime(Date createTime) {
this.createTime = createTime;
} public Date getUpdateTime() {
return updateTime;
} public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
上一篇:图片旋转+剪裁js插件(兼容各浏览器) « 张鑫旭-鑫空间-鑫生活


下一篇:网络编程一定要看过的socket另一座大山