我有以下项目:
@Entity
@Table(name = "A")
public class A{
@Id
private Long id = null;
@OneToMany(mappedBy = "a_1", cascade = CascadeType.ALL,
fetch = FetchType.EAGER)
private List<B> bs;
}
@Entity
@Table(name = "B")
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "BTYPE",
discriminatorType = DiscriminatorType.STRING)
public abstract class B{
@Id
private Long id = null;
@Embedded
private C c;
@ManyToOne(cascade=CascadeType.REFRESH)
@JoinColumn(name="a_id")
@XmlTransient
private A a_1;
}
@Embeddable
public class C {
@OneToMany(mappedBy = "b_1", cascade = CascadeType.ALL,
fetch = FetchType.EAGER))
private Set<D> ds;
}
@Entity
@Table(name = "D")
public class D {
@ManyToOne(cascade=CascadeType.REFRESH)
@JoinColumn(name="b_id")
private B b_1;
}
@Entity
@DiscriminatorValue(value = "X_D")
public class X extends B {
}
@Entity
@DiscriminatorValue(value = "Y_D")
public class Y extends B {
}
所有这些类都实现了Serializable,除了X和Y
当我调用entityManager.merge(A)时 我明白了:
引起:org.hibernate.InstantiationException:无法实例化抽象类或接口:B
请问有人帮我吗?
提前举手
答案 0 :(得分:-1)
我看到类似的问题,人们不得不在这里制作具体的课程(X和Y)以实现Serializable
以使其发挥作用