继承老报着错误,好纠结啊

我心java 发布于 2012/05/22 21:53
阅读 166
收藏 0

n thread "main" org.hibernate.AnnotationException: No identifier specified for entity: com.cc.nn.Student1
 at org.hibernate.cfg.InheritanceState.determineDefaultAccessType(InheritanceState.java:268)
 at org.hibernate.cfg.InheritanceState.getElementsToProcess(InheritanceState.java:223)
 at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:712)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4028)
 at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3986)
 at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1436)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1894)
 at com.mm.cc.test.main(test.java:17)
person类

import javax.persistence.GeneratedValue;
import javax.persistence.*;
import javax.persistence.Inheritance;

import org.hibernate.annotations.Entity;
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE) //用来标记区分的字段类型
@DiscriminatorColumn(
    name="person",
    discriminatorType=DiscriminatorType.STRING
 
)
 @DiscriminatorValue("person")
public class Person {
  private int id;
  private String name;
  @Id
  @GeneratedValue(strategy=GenerationType.IDENTITY)
  @Column(name = "id", nullable = false)
public int getId() {
 return id;
}
public void setId(int id) {
 this.id = id;
}
public String getName() {
 return name;
}
public void setName(String name) {
 this.name = name;
}
 
}
student类

import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

@Entity
@DiscriminatorValue("student11")
public class Student1 extends Person {
 
 private String banji;

 public String getBanji() {
  return banji;
 }

 public void setBanji(String banji) {
  this.banji = banji;
 }

 
 
}

 

 

 

加载中
返回顶部
顶部