java Hibernate 映射 - “无法确定类型”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2457733/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Hibernate mapping - "Could not determine type"
提问by Pool
I currently have the following objects persisting successfully:
我目前有以下对象成功持久化:
- Personfirst name, etc.
- Examstitle, date, etc.
- 人名等
- 考试名称、日期等。
I'd like to now create a third table Exam results. For this table I believe it should be person ID, exam ID and result, and this is a many to many relationship.
我现在想创建第三个表Exam results。对于这张表,我认为应该是人 ID、考试 ID 和结果,这是一个多对多的关系。
@Entity
public class ExamResult {
private Exam exam;
private Person person;
private double value;
@Id
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="EXAM_ID")
public Exam getExam() {
return exam;
}
public void setExam(Exam exam) {
this.exam = exam;
}
@Id
@ManyToOne( cascade = {CascadeType.PERSIST, CascadeType.MERGE} )
@JoinColumn(name="PERSON_ID")
public Person getPerson() {
return person;
}
public void setPerson(Person person) {
this.person = person;
}
public double getValue() {
return value;
}
public void setValue(double value) {
this.value = value;
}
}
The error:
错误:
org.hibernate.MappingException: Could not determine type for: Person, at table: ExamResult, for columns: [org.hibernate.mapping.Column(person)]
org.hibernate.MappingException:无法确定类型:Person,在表:ExamResult,对于列:[org.hibernate.mapping.Column(person)]
I think I may be going about this the wrong way, but I can't work out how to proceed with this relationship from the tutorial.
我想我可能会以错误的方式解决这个问题,但是我无法从教程中弄清楚如何处理这种关系 。
Any ideas?
有任何想法吗?

