为什么hibernate查询不到结果,我用语句在oracle中查询就可以(相同查询条件)?
Stringhql="fromEmployeewhereid=?andpwd=?";List<Employee>list=sessionFactory.getCurren...
String hql="from Employee where id=? and pwd=?";
List<Employee> list=sessionFactory.getCurrentSession().createQuery(hql)
.setInteger(0, e.getId()).setString(1, e.getPwd()).list();
if (list.size()==1) {
return list.get(0);
}else {
return null;
}
Hibernate: select employee0_.id as id0_, employee0_.name as name0_, employee0_.email as email0_, employee0_.hiredate as hiredate0_, employee0_.salary as salary0_, employee0_.pwd as pwd0_, employee0_.grade as grade0_ from employee employee0_ where employee0_.id=? and employee0_.pwd=?
我把上面的查询语句放到oracle中查询,有一个值的,但是在service结果中就是返回为空(null); 展开
List<Employee> list=sessionFactory.getCurrentSession().createQuery(hql)
.setInteger(0, e.getId()).setString(1, e.getPwd()).list();
if (list.size()==1) {
return list.get(0);
}else {
return null;
}
Hibernate: select employee0_.id as id0_, employee0_.name as name0_, employee0_.email as email0_, employee0_.hiredate as hiredate0_, employee0_.salary as salary0_, employee0_.pwd as pwd0_, employee0_.grade as grade0_ from employee employee0_ where employee0_.id=? and employee0_.pwd=?
我把上面的查询语句放到oracle中查询,有一个值的,但是在service结果中就是返回为空(null); 展开
2个回答
展开全部
将字段类型改为varchar2类型 (项目中使用,推荐使用),另外建议优先使用varchar2类型
http://blog.csdn.net/honghailiang888/article/details/73770344
mysql, mssqlserver 都没问题,就是oracle这个会查询不出,改一下字段类型就好了
http://blog.csdn.net/honghailiang888/article/details/73770344
mysql, mssqlserver 都没问题,就是oracle这个会查询不出,改一下字段类型就好了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询