This is because you don't have course_id property in Module.class. In criterions you must use properties names and not column names. Or you don't have getter/setter such as getCourse_id()
Spring Hibernate database query not working
-
29-05-2022 - |
Frage
Got this line to get list of "modules" by "course_id" from the database:
return sessionFactory.getCurrentSession().createCriteria(Module.class).add(Restrictions.eq("course_id",course_id)).list();
Upon run it fails with this error:
WARNING: StandardWrapperValve[dispatcher]: PWC1406: Servlet.service() for servlet dispatcher threw exception
org.hibernate.QueryException: could not resolve property: course_id of: miniVLE.beans.Module
Course_id - is a String. Could that be because course_id is a foreign key in the database?
@ManyToOne
@JoinColumn(name="course_id")
private Course course;
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow