package com.ssj.bean.common.framework.core.domain;

import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * 
 * 类名称：BaseEntity<br>
 * 类描述： 实体类，所有的实体对象都需要继承该基类<br>
 * 重要：使用@MappedSupperClass注解取代原来的@Entity和@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)注解<br>
 * 原因是：@Entity注解会导致所有子类都无法使用二级缓存，而且@MappedSupperClass不需要对应数据库table<br>
 * @version v1.0
 *
 */
@MappedSuperclass
public abstract class BaseEntity extends PersistentEntity {

    private static final long serialVersionUID = 1534056643006312407L;

    /*
     * 主键
     */
    private String id;

    public BaseEntity() {

    }

    @Id
    @GeneratedValue( strategy = GenerationType.AUTO,  generator = "id") //指定生成器名称
    @GenericGenerator(name = "id", strategy = "com.ssj.framework.idworker.IDGenerator")
    @Column(length = 32, nullable = false)
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
