日期:2014-05-17  浏览次数:20721 次

hql语法 查询对象的区别
不懂hql语法,第一个是学习时候的id查询对象的方法,后面个是实际项目中的方法,有什么区别啊??特别是这句话:where lower(user.id) like lower(:id) and user.product is null什么意思啊??
	public User getUser(String id) {
String hql = "from User user where user.id=?";
Query query = sessionFactory.getCurrentSession().createQuery(hql);
query.setString(0, id);
return (User)query.uniqueResult();
}

public User findById(String id) {
if (id == null) {
return null;
}
String hql = "select user from User user where lower(user.id) like lower(:id) and user.product is null";
try {
return this.entityManager.createQuery(hql, User.class).setFlushMode(FlushModeType.COMMIT).setParameter("id", "%"+id).getSingleResult();
} catch(NoResultException e) {
// TODO: handle exception
}
return null;
}
java hql语法

------解决方案--------------------
去查文档啊,这个是 HQL 的函数:将该列结果含有的字母全部大写