代码类TypeCompetence
的代码@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "typeCompetence")
public Set<Criteres> getCritereses() {
return this.critereses;
}
Criteres类的代码
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_type_compete")
public TypeCompetence getTypeCompetence() {
return this.typeCompetence;
}
CriteresDAO类的代码
public List<Criteres> FindidAspetComp(){
String queryString = "from Criteres c ,TypeCompetence t where c.id_type_compete = t.id_type_compete AND t.id_type_compete = 4 ";
return getHibernateTemplate().find(queryString);
}
错误
javax.servlet.ServletException: could not resolve property: id_type_compete of: tn.com.ModuleEVL.domaine.Criteres [from tn.com.ModuleEVL.domaine.Criteres c ,tn.com.ModuleEVL.domaine.TypeCompetence t where c.id_type_compete = t.id_type_compete AND t.id_type_compete = 4 ];
答案 0 :(得分:1)
HQL 从不使用表名和列名。它始终使用实体名称和字段/属性名称。你所需要的只是
select c from Criteres c where c.typeCompetence.id = 4
阅读the documentation。请修改你的命名。实体不应具有复数形式,因此Criteres
应命名为Critere
。 getCritereses()
应命名为getCriteres()
。我甚至无法理解FindidAspetComp()
应该是什么意思。它不遵守Java命名约定:方法以小写字母开头,并且是camelCaded ..