org.hibernate.MappingException:无法确定以下类型:

时间:2017-06-10 17:09:50

标签: java hibernate jpa

  

org.hibernate.MappingException:无法确定以下类型:   com.qoobico.remindme.server.entity.Group,at table:student,for   columns:[org.hibernate.mapping.Column(group)]

我读了所有帖子abot这个例外,但我无法解决这个问题。似乎一切都是全然的,但我仍然得到它:

Group.java

public static Lazy<string> Name { get; } = new Lazy<string>(() => ReadNameFromFile());

}

Student.java

@Entity
@Table(name = "party")
public class Group {
@Id
@GeneratedValue(generator = "increment")
@GenericGenerator(name="increment", strategy = "increment")
private int id_group;

@Column(name = "groupName", nullable = false)
private String groupName;

@Column(name = "tutorName", nullable = false)
private String tutorName;


@OneToMany(targetEntity = Student.class, 
           mappedBy = "group", 
           cascade = CascadeType.ALL, 
           fetch = FetchType.EAGER)
private List<Student> student;


public Group(){

}


public int getId_group() {
    return id_group;
}

public void setId_group(int id_group) {
    this.id_group = id_group;
}

public String getGroupName() {
    return groupName;
}

public void setGroupName(String groupName) {
    this.groupName = groupName;
}

public String getTutorName() {
    return tutorName;
}

public void setTutorName(String tutorName) {
    this.tutorName = tutorName;
}


public List<Student> getStudent() {
    return student;
}

public void setStudent(List<Student> student) {
    this.student = student;
}

1 个答案:

答案 0 :(得分:1)

Student对于属性group的映射应为:

@ManyToOne
@JoinColumn(name = "group_id")
private Group group;

您无法在字段和属性级别混合注释。将这些注释移动到字段中,事情将按预期工作。