Domanda

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;
È stato utile?

Soluzione

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()

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top