many to one could not resolve property
今天在做一个功能的时候
遇到了。一个Could not resolve property 的问题。
配置文件如下:
- <many-to-one name="user" class="Users" column="StudentExam_user_fid" cascade="all" ></many-to-one>
查询代码:
- Criteria crt = session.createCriteria(StudentExam.class).add(Restrictions.eq("exam.id", ExamId)).add(
- Restrictions.eq("reading", reading)).add(Restrictions.like("user.truename", name));
- return crt.setFirstResult(start).setMaxResults(max).list();
在网上找了好久。所有人给的理由都是“对照配置文件以及实体类,是否写错了字段名称”
在我一再的确认下,字段名称没有任何错误……
而且使用user.id是可以进行查询的。除了这个以外。别的都不可以用!
于是开始对配置文件进行修改。尝试了 lazy设置为false 等等。。想对应的修改
Users配置文件的修改。未果
最后,经过各种挣扎。以及Hibernate相关API的查找。最终终于找出解决办法
- Criteria crt = session.createCriteria(StudentExam.class).add(Restrictions.eq("exam.id", ExamId)).add(
- Restrictions.eq("reading", reading)).createCriteria("user").add(Restrictions.like("truename", name));
对。就是这样写。在使用完StudentExam里的属性后。
- .createCriteria("user")
设置到user实体里。然后再选择属性
注:这里的user是StudentExam类中的名称
注意一般情况下都是 user这个类的关系
many to one could not resolve property的更多相关文章
- nested exception is org.hibernate.QueryException: could not resolve property
SSH框架出现了下面的错误: nested exception is org.hibernate.QueryException: could not resolve property 检查了hbm.x ...
- org.hibernate.QueryException: could not resolve property
org.hibernate.QueryException: could not resolve property HibernateSQLXML org.hibernate.QueryExcepti ...
- org.hibernate.QueryException: could not resolve property: address of:
Hibernate: select count(*) as y0_ from test.course this_ org.hibernate.QueryException: could not res ...
- could not resolve property问题(ssh框架)
could not resolve property不能解析属性问题, 刚开始把hql语句中的"from User user where user.user_name = '"+u ...
- could not resolve property: leader_id of: pojo.Project
https://www.cnblogs.com/zhaocundang/p/9211270.html hibernate 双向1对多 出现问题 外键解析错误! log4j:WARN No append ...
- could not resolve property
could not resolve property(无法解析属性) 顾名思义在写hql语句的时候,属性写错了! 请检查大小写,是实体类的,不是数据库表的! 一个一个检查,仔细看!
- 常见Hibernate报错处理:出现“org.hibernate.QueryException: could not resolve property”和 is not mapped和could not locate named parameter错误的解决
正确写法: @Override @SuppressWarnings("unchecked") public List<Device> queryOSDevice(Str ...
- could not resolve property(无法解析属性)
could not resolve property(无法解析属性) 顾名思义在写hql语句的时候,属性写错了! 请检查大小写,是实体类的,不是数据库表的! 一个一个检查,仔细看!
- Hibernate-org.hibernate.QueryException: could not resolve property: code of:
查询的时候有个属性跟表里的字段不符合,没有完全匹配上.
随机推荐
- CSRF(跨站请求伪造)攻击方式
一.CSRF是什么? CSRF(Cross-site request forgery),中文名称:跨站请求伪造,也被称为:one click attack/session riding,缩写为:CSR ...
- 15 个最佳的 jQuery 表格插件
现如今,网站开发设计的需求会要求自动适应所有移动设备,即响应式网站: 在开发网站时必须考虑对平板设备融合 fluid(流)和自适应性特点. 大多数网站设计要靠margins, guides, rows ...
- Sublime Text 编辑器
1.从http://www.sublimetext.com/2 下载Sublime Text 2编辑器. 2.安装Package Control 管理器,用于管理和安装插件包. 下载地址:https: ...
- Map中放置类指针并实现调用
工作中使用到多进程通信,利用到了map以及multimap来进行实现. 需要做一个简单测试例子,直接上代码. /* * main.cpp * Created on: Oct 28, 2013 * Au ...
- hdu 2389(最大匹配bfs版)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2389 思路:纯裸的一个最大匹配题,不过悲摧的是以前一直用的dfs版一直过不了,TLE无数次啊,然后改成 ...
- Spring中RedirectAttributes对象重定向传参
Spring3中的FlashAttribute 为 了防止用户刷新重复提交,save操作之后一般会redirect到另一个页面,同时带点操作成功的提示信息.因为是Redirect,Request里 的 ...
- Spine的纹理导出问题
发现美术给过来的资源,集合到unity后,发现用Spine的默认材质Spine/Skeleton有毛边问题.对比demo的图片后发现demo的图片(都是png格式)没有白色块,而自己的图片有. 原因是 ...
- Java7编程 高级进阶学习笔记--嵌套类
定义: 在一个类中定义的类叫做嵌套类. 作用: 1.允许对相关类进行逻辑分组 2.增强了代码的封装性 3.使代码具有更强的可读性和维护性 使用方式: package com.cmz.baseTest; ...
- 程序空间(Program memory)
The computer program memory is organized into the following: Data Segment (Data + BSS + Heap) Stack ...
- TestDirector域或工程用户的管理
一.添加用户 单击界面上的"Users"按钮,进入如下图: 我们可以添加新用户,删除用户,导入用户,修改用户密码,用户的详细信息. 1.单击"New"按钮为域或 ...