/******************************************************************************* * Copyright (c) 2005, 2014 springside.github.io * * Licensed under the Apache License, Version 2.0 (the "License"); *******************************************************************************/ package com.yihu.jw; import org.hibernate.annotations.GenericGenerator; 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.util.Date; /** * 统一定义id的entity基类. * * 基类统一定义id的属性名称、数据类型、列名映射及生成策略. * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。 * * @author calvin */ // JPA 基类的标识 @MappedSuperclass @EntityListeners(AuditingEntityListener.class) public abstract class IdEntity { @Id @GeneratedValue(generator = "uuid") @GenericGenerator(name = "uuid", strategy = "uuid") protected String id; // 非业务主键 public String getId() { return id; } public void setId(String id) { this.id = id; } }