Jpa 为什么eclipselink 2.5.0不支持子类中的Override TableGenerator或SequenceGenerator,而Hibrate支持?
如标题所示 在基本实体类中共享Id定义不是很常见吗?例如:Jpa 为什么eclipselink 2.5.0不支持子类中的Override TableGenerator或SequenceGenerator,而Hibrate支持?,jpa,eclipselink,Jpa,Eclipselink,如标题所示 在基本实体类中共享Id定义不是很常见吗?例如: @MappedSuperclass public abstract class BaseEntity implements Serializable { @Id @GeneratedValue(strategy = GenerationType.TABLE) private Long id; public Long getId() {return this.id;} public void s
@MappedSuperclass
public abstract class BaseEntity implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private Long id;
public Long getId() {return this.id;}
public void setId(Long id) { this.id = id; }
...
}
在子类中,假设其工作如下:
@Entity
@Table(name = "sub_entity_table")
@TableGenerator(name = "SUB_ENTITY_SEQUENCE", initialValue = 1, allocationSize = 100)
public class SubEntity extends BaseEntity {
...
}
由于未指定GeneratedValue.generator,因此应指定默认值。默认生成器名称为:
A.实体类中最接近的向上TableGenerator定义,就像继承一样。
B如果“a”中的情况不存在,则使用JPA提供者提供的文本值,如SEQ_GEN_TABLE
我非常喜欢日食。我真的希望在下一个eclipselink版本中包含此功能。:) 使用EclipseLink 2.5.2时也会遇到同样的问题。