Ilya Kulikov
Ilya Kulikov

Reputation: 61

org.hibernate.MappingException: Could not determine type for:

org.hibernate.MappingException: Could not determine type for: com.qoobico.remindme.server.entity.Group, at table: student, for columns: [org.hibernate.mapping.Column(group)]

i read all post abot this exception, but i can't fix that. it seems tat everything is allrighrt, but i still got it :

Group.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;
}

}

Student.java

    @Entity
@Table(name ="student")
public class Student {

    @Id
    @GeneratedValue(generator = "increment")
    @GenericGenerator(name="increment", strategy = "increment")
    private int id_student;


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

    @Column(name = "formOfAducation")
    private String formOfAducation;

    @Column(name = "group")
    private Group group;

    @Column(name = "studentCourse")
    private String studentCourse;

    @Column(name = "studentSpecializatio")
    private String studentSpecializatio;

    @Column(name = "studentBookName")
    private String studentBookName;

    @Column(name = "studentGender")
    private String studentGender;

    public Student(){
    }

    public int getId_student() {
        return id_student;
    }

    public void setId_student(int id_student) {
        this.id_student = id_student;
    }

    public String getStudentName() {
        return studentName;
    }

    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }

    public String getFormOfAducation() {
        return formOfAducation;
    }

    public void setFormOfAducation(String formOfAducation) {
        this.formOfAducation = formOfAducation;
    }

    @ManyToOne
    @JoinColumn(name ="id_group")
    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public String getStudentCourse() {
        return studentCourse;
    }

    public void setStudentCourse(String studentCourse) {
        this.studentCourse = studentCourse;
    }

    public String getStudentSpecializatio() {
        return studentSpecializatio;
    }

    public void setStudentSpecializatio(String studentSpecializatio) {
        this.studentSpecializatio = studentSpecializatio;
    }

    public String getStudentBookName() {
        return studentBookName;
    }

    public void setStudentBookName(String studentBookName) {
        this.studentBookName = studentBookName;
    }

    public String getStudentGender() {
        return studentGender;
    }

    public void setStudentGender(String studentGender) {
        this.studentGender = studentGender;
    }
}

Upvotes: 2

Views: 6913

Answers (1)

Naros
Naros

Reputation: 21153

The mapping in Student for property group should be:

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

You can't mix the annotations at field and property level. Move those annotations to the field and things will work as you expect.

Upvotes: 2

Related Questions