Hibernate mapping - "Could not determine type"

Posted by Pool on Stack Overflow See other posts from Stack Overflow or by Pool
Published on 2010-03-16T20:10:54Z Indexed on 2010/03/16 20:11 UTC
Read the original article Hit count: 355

I currently have the following objects persisting successfully:

  • Person first name, etc.
  • Exams title, 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.

@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)]

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?

© Stack Overflow or respective owner

Related posts about java

Related posts about hibernate