问题描述
- 各位大神,小弟关于hibernate有一些疑问
-
我是实体类继承建立数据库表的问题
我先建立了一个
@MappedSuperclass
public abstract class AbEntity {
@Id
@GeneratedValue
private Integer id;
}
然后建立了User类 继承它
@Entity
@Table(name="user")
@Inheritance(strategy=InheritanceType.JOINED)
public class User extends AbstractEntity {
private String password;
private String name;
}
又建立了一个类 user2 继承User类
@Entity
@Table(name="user2")
public class Coach extends User {
private String age;
}
向数据库插入数据以后爆出了这样的错误
org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Request processing failed; nested exception is org.hibernate.AssertionFailure: null id in com.icode.core.model.coach.Coach entry (don't flush the Session after an exception occurs)] with root cause
org.hibernate.AssertionFailure: null id in com.icode.core.model.coach.Coach entry (don't flush the Session after an exception occurs)哪位大神帮助一下,谢谢了!
解决方案
跪求哪位大神来解答一下啊!
时间: 2024-10-03 04:16:13