sqlServer2008 Hibernate 查询问题!望高手解惑!
时间:2011-08-21
来源:互联网
这是一个查询方法,总是报:Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: 关键字 'User' 附近有语法错误。
public User findUserByNameAndPsw(String userId, String psw) {
String hql="from User us where us.id=? and us.psw=?";
List<User> us=getHibernateTemplate().find(hql,new String[]{userId,psw});
System.out.println(us.size());
if(us.size()!=0&&us!=null)
{
return us.get(0);
}
else
{
return null;
}
}
奇怪的是同样的程序代码我在oracle中能用,为啥我换成sqlServer2008就不行了呢?高手解惑啊!
public User findUserByNameAndPsw(String userId, String psw) {
String hql="from User us where us.id=? and us.psw=?";
List<User> us=getHibernateTemplate().find(hql,new String[]{userId,psw});
System.out.println(us.size());
if(us.size()!=0&&us!=null)
{
return us.get(0);
}
else
{
return null;
}
}
奇怪的是同样的程序代码我在oracle中能用,为啥我换成sqlServer2008就不行了呢?高手解惑啊!
作者: han3970956 发布时间: 2011-08-21
from User as us where us.id=? and us.psw=?
哥们oracle和sql语法不一样 的
哥们oracle和sql语法不一样 的
作者: LMAOhuaNL 发布时间: 2011-08-21
引用 1 楼 lmaohuanl 的回复:
from User as us where us.id=? and us.psw=?
哥们oracle和sql语法不一样 的
我用你说的也是报一样的错误啊 ,大哥 from User as us where us.id=? and us.psw=?
哥们oracle和sql语法不一样 的
作者: han3970956 发布时间: 2011-08-21
String hql="from User us where us.id=:id and us.psw=:psw";
Map<String,String> map=new HashMap<String,String>();
map.put("id",userId);
map.put("pws",pws);
你这样试试看,差不多是这样的,好久没用这种方法了
Map<String,String> map=new HashMap<String,String>();
map.put("id",userId);
map.put("pws",pws);
你这样试试看,差不多是这样的,好久没用这种方法了
作者: mmqswan 发布时间: 2011-08-21
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28