【发布时间】:2014-05-15 19:31:31
【问题描述】:
我有一个休眠实体超类:
@MappedSuperclass
public abstract class Pojo_Entity_SuperClass
{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="ID", unique=true, nullable=false, precision=18, scale=0)
protected long id;
public Long getId() {return id;}
//Other entity fields and methods
}
接下来我像这样继承其他实体类:
@Entity
@Table(name="USR")
public class Usr extends Pojo_Entity_SuperClass
{
//Columns, fileds and others
}
但在某些情况下,我想在没有 @GeneratedValue 注释的情况下继承具有“id”字段的实体。 问题是 - 如何在子类中为 id 禁用 @GeneratedValue 注释?
【问题讨论】:
标签: java hibernate jpa orm hibernate-mapping