0

I am trying to get the integer values into a drop down menu from table called Student_info where student_id is the primary key , in another table student_id is foreign key so I am

<p:selectOneMenu value="#{studentMarksController.studentMarksInfoApp.studentMarksInfoAdd.studentId}" id="student_id" required="true" requiredMessage="Student Id is required" >
    <f:selectItems value="#{studentMarksController.studentMarksInfoApp.findStudentMarksInfoSt_id()}" />
    <f:convertNumber   />
</p:selectOneMenu>

in another table student_id is foreign key so I am using below query to get values from student_info

public List<StudentInfo> findStudentMarksInfoStuId(){
    EntityManager em=getEntityManager();
    try{

        Query query=em.createQuery("SELECT s.studentId FROM StudentInfo s");
        return query.getResultList();
    }finally{
        em.close();
    }

}

the problem here is that in entity class Student_marks_allocation foreign key student_id data type is of object so while inserting its giving error as not a valid number

@JoinColumn(name = "STUDENT_ID", referencedColumnName = "STUDENT_ID")
@ManyToOne(optional = false)
private StudentInfo studentId;
Passerby
  • 9,715
  • 2
  • 33
  • 50

1 Answers1

0

You will need a converter and equals and hashcode methods in bean Class in your case Student_info

S_intg
  • 182
  • 1
  • 10