org.hibernate.QueryException: could not resolve property:

  项目一直报这个错误,网上也搜了很多相关的,有的说 hql 查询语句和 实体类没有对应起来,可是我的都对应了,还是不知道问题在哪。上代码

  

    public List<Survey> findMySurveys(User user) {
        String hql = "from Survey s join s.user u where u.id = ?" ;
        List<Survey> list = surveyDao.findEntityByHql(hql, user.getId()) ;
        return list ;
    }

对应的 hbm.xml:

 <many-to-one name="uesr" class="com.ysp.surveypark.model.User">
            <column name="UESR_ID" />
 </many-to-one>

实体类(set\get方法略):

public class Survey {
    private Integer id ;
    private String title = "未命名" ;
    private String preText = "上一步" ;
    private String nextText = "下一步" ;
    private String exitText = "退出" ;
    private String doneText = "完成" ;
    //创建时间
    private Date createTime = new Date() ;
    //创建 Survey-User n-1 的关联关系
    private User uesr ;
    //创建 Survey-Page 1-n 的关联关系
    private Set<Page> pages = new HashSet<Page>() ;
}

有谁知道错在哪嘛,实在没办法了

时间: 2024-08-06 20:02:13

org.hibernate.QueryException: could not resolve property:的相关文章

数据库异常整理:org.hibernate.QueryException: could not resolve property: “mStation”

最近用hibernate作数据库查询,结果遇到问题: org.hibernate.QueryException: could not resolve property: 'mStation'of  经过各个步骤检查,还是没找到方法. 在此,整理一下这个问题的导致可能原因: 一.排查HQL语句中的类字段,看是否是java类中的字段,不要是数据库中的字段: 二.排查各个字段是否与类中字段一致,绝大多数可能是由于字段不匹配导致的问题: 三.如果以上两部都检查没有问题,那么很可能就是JavaBean命名

could not resolve property: leader_id of: pojo.Project

https://www.cnblogs.com/zhaocundang/p/9211270.html hibernate 双向1对多 出现问题 外键解析错误! log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment). log4j:WARN Please initialize the log4j system properly. 1 Exception in thread "main&quo

many to one could not resolve property

今天在做一个功能的时候 遇到了.一个Could not resolve property 的问题. 配置文件如下: Java代码   <many-to-one name="user"  class="Users" column="StudentExam_user_fid" cascade="all" ></many-to-one> 查询代码: Java代码   Criteria crt = sessio

could not resolve property: name of:

spring date jpa 错误:could not resolve property: name of: 在写 查询的时候,把实体类的属性写错了,即 sql 语句中字段与实体类中属性没有对应,造成无法解析. @Query("from Product p where p.id.productName like :name") List<Product> getInfoByName(@Param("name")String name,Pageable

could not resolve property

could not resolve property:出现此错误我们在Wdzlog.hbm.xml文件下加上<property name="name" column="name"/>便可

解决org.hibernate.QueryException illegal attempt to dereference collection 异常错误

在项目中,会遇到一对多的实体关系映射,而恰恰又要查出关联的实体属性,在HQL中使用join语句关联两个实体对象,如下代码: 1 select new CustomerRequirement(c.pName,c.salesMan,c.pDate) from CustomerRequirement c inner join c.requirementDeatils r on c = c.requirementDeatils.customerRequirement 运行发现报如下错误: org.hib

weblogic 下异常 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken

项目之前在 Tomcat 环境下一直都正常运行,今天应客户要求需要迁移到 webLogic 10.3.6 下, 部署后竟然抛出了 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken 异常,经过一番搜索后弄明白了问题的产生原因及解决方法. 问题原因 Hibernate3 采用新的基于 antlr 的 HQL/SQL 查询翻译器,在 hibernate3 中需要用到 antlr,然而

Hibernate常见错误整理

Hibernate常见错误合集 1.错误:object references an unsaved transient instance - save the transient instance before flushing: com.xxxx.bean.java.Sysblog; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instanc

指定查询条件,查询对应的集合List(单表)

TestDao.java(测试类) @Test public void findCollectionByConditionNoPage(){  ApplicationContext ac = new ClassPathXmlApplicationContext("beans.xml");  IElecTextService elecTextService = (IElecTextService) ac.getBean(IElecTextService.SERVICE_NAME);