Java tutorial
/* * Copyright 2016-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.wiiyaya.framework.provider.tools; import org.springframework.data.annotation.CreatedBy; import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.LastModifiedBy; import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.jpa.domain.support.AuditingEntityListener; import javax.persistence.*; import java.io.Serializable; import java.util.Date; /** * <p></p> * * <p>???</p> * * <p></p> * * @author wiiyaya * * @param <U> ? * @param <PK> ? */ @MappedSuperclass @EntityListeners({ AuditingEntityListener.class }) public class BaseEntity<U, PK extends Serializable> implements Serializable { private static final long serialVersionUID = -5554308939380869754L; private PK id; private Integer version; private U createdBy; private Date createTime; private U updateBy; private Date updateTime; @Id // @GeneratedValue(generator = FwConstants.SEQ_GEN_NAME) @GeneratedValue(strategy = GenerationType.IDENTITY) public PK getId() { return id; } public void setId(final PK id) { this.id = id; } @Version @Column public Integer getVersion() { return version; } public void setVersion(Integer version) { this.version = version; } @CreatedBy @Column(updatable = false) public U getCreatedBy() { return createdBy; } public void setCreatedBy(U createdBy) { this.createdBy = createdBy; } @CreatedDate @Column(updatable = false) public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { this.createTime = createTime; } @LastModifiedBy @Column public U getUpdateBy() { return updateBy; } public void setUpdateBy(U updateBy) { this.updateBy = updateBy; } @LastModifiedDate @Column public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } }