hql语句怎样修改
public List<TUser> getAllUsersByPage(TUser user, Pager pager) {
String sql = "from TUser where groupId != 0";
if (user != null){
if (user.getUserName() != null && !user.getUserName().equals("")){
sql += " and userName like '%" + user.getUserName() +"%'";
}
}
if(user !=null){
if(user.getGroupId() !=null && !user.getGroupId().equals("")){
sql +=" and groupId = "+ user.getGroupId() +" ";
}
}
所报异常如下:
unexpected token: 2 near line 1, column 70 [from com.tcs.sysmanager.pojo.TUser where groupId != 0 and groupId in 2 ]
String sql = "from TUser where groupId != 0";
if (user != null){
if (user.getUserName() != null && !user.getUserName().equals("")){
sql += " and userName like '%" + user.getUserName() +"%'";
}
}
if(user !=null){
if(user.getGroupId() !=null && !user.getGroupId().equals("")){
sql +=" and groupId = "+ user.getGroupId() +" ";
}
}
所报异常如下:
unexpected token: 2 near line 1, column 70 [from com.tcs.sysmanager.pojo.TUser where groupId != 0 and groupId in 2 ]
...全文
相关推荐
Hibernate框架]Hql语句in中带参数的写法
Hibernate框架Hql语句in中带参数的写法Hibernate框架中,在使用HQL语句时,需要传递参数,而在HQL语句中使用in关键字时,需要特别注意参数的传递方式。
HQL与SQL的区别
它提供了一套完整的语法体系,用于创建、修改、查询和管理数据库中的数据。SQL的强大之处在于其通用性,能够处理复杂的数据库操作,包括数据定义、数据操纵、数据控制和事务管理。
hql的增删改查
字符串,其中包含计数表达式和条件语句。
Java的Hibernate框架中用于操作数据库的HQL语句讲解
例如,`from User` 在HQL中表示从User实体类中获取所有实例,而不仅仅是从名为User的数据库表中检索数据。Hibernate会自动将HQL语句转换为相应的SQL语句执行。
HQL语句大全
### HQL语句大全:深入理解与应用#### 概述HQL(Hibernate Query Language)是Hibernate框架中用于查询数据库的一种面向对象的查询语言。


Web 开发
