有一个基本实体类,其ID以这种方式声明:
@MappedSuperclass
public abstract class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;...}
用户实体继承自此类。
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class User extends BaseEntity {...}
AdminUser等特定用户实体继承自User class;
@Entity
@Table(name = "AdminUsers")
public class AdminUser extends User {...}
有没有办法在从抽象用户类继承的不同类型的用户之间保留唯一ID?