提问者:小点点

无法保存鉴别器值。(JPASpring数据Hibernate)


我有以下情况:

基类:

@Entity(name = "BaseEntity")
@Inheritance(strategy= InheritanceType.JOINED)
@DiscriminatorColumn(name="DISCR_COLUMN", discriminatorType = DiscriminatorType.STRING)
@Table(name = "base")
@DiscriminatorOptions(insert = true,force=true)
public abstract class Base implements Serializable {

子类:

@Entity(name = "SubclassEntity")
@DiscriminatorValue("A")
@Table(name="subclass")
@PrimaryKeyJoinColumn(name = "subclass_id", referencedColumnName = "base_id")
@DiscriminatorOptions(insert = true,force=true)
public class Subclass extends Base {

存储库:

public interface BaseRepository extends JpaRepository<Base, String>, JpaSpecificationExecutor<Base> {

我唯一的问题是当我想创建一个新的子类

存储. saveAndFlush(基础);

鉴别器值未保存,DB显示为NULL。我认为它是由Hibernate自动设置的,不是吗?


共1个答案

匿名用户

注意:见下面的评论(!)

根据http://en.m.wikibooks.org/wiki/Java_Persistence/Inheritance部分“连接,多表继承”:

Hibernate不支持继承策略的鉴别器列:已加入。