from UserPojo where uemail like ? and username like ? %123% %123% %123% %123% queryString: from UserPojo where uemail like ? and username like ?有值的时候也不行
你debug 进去看看具体的值,具体的信息。
语句的原型是 this.sql="from UserPojo where uemail like ? and username like ?"; this.objs=new Object[]{"%"+uemail+"%","%"+username+"%"};
debug里面调试的时候objs里面的值都没有问题,但在执行色图parameter时值没有进去
为什么没set 进去,debug 你看下。objs 里面具体信息
不填数据时objs里面是[%%, %%] 填了数据时是[%123%, %123%]; 在query中始终是from UserPojo where uemail like ? and username like ?
不知你怎么写 。写死看看 参照 return session.createQuery("from xxx a where a.x like ? or a.xx like ? order by a.xx") .setParameter(0, queryStr1 + "%") .setParameter(1, queryStr 2+ "%") .setFirstResult((pageNo - 1) * pageSize) .setMaxResults(pageSize)
.list();
写死之后还是进不去 结果还是 from UserPojo where uemail like ? and username like ?queryString: from UserPojo where uemail like ? and username like ?queryString: from UserPojo where uemail like ? and username like ?Hibernate: select userpojo0_.id as id2_, userpojo0_.uemail as uemail2_, userpojo0_.password as password2_, userpojo0_.username as username2_, userpojo0_.uage as uage2_, userpojo0_.sex as sex2_, userpojo0_.roleid as roleid2_ from user userpojo0_ where (userpojo0_.uemail like ?) and (userpojo0_.username like ?) limit ?Hibernate: select count(*) as col_0_0_ from user userpojo0_ where (userpojo0_.uemail like ?) and (userpojo0_.username like ?)我不知道那个limit是啥意思了
看你的sql像是分页查询,但是怎么会用到like关键字
还有打印为什么会出来%%,你把百分号也拼到了objs的对象里了?
我用的事模糊查询,但是objs中的数据进不去
toString 的结果是一样的
%123%
%123%
%123%
%123%
queryString: from UserPojo where uemail like ? and username like ?有值的时候也不行
语句的原型是
this.sql="from UserPojo where uemail like ? and username like ?";
this.objs=new Object[]{"%"+uemail+"%","%"+username+"%"};
debug里面调试的时候objs里面的值都没有问题,但在执行色图parameter时值没有进去
不填数据时objs里面是[%%, %%]
填了数据时是[%123%, %123%];
在query中始终是from UserPojo where uemail like ? and username like ?
.setParameter(0, queryStr1 + "%")
.setParameter(1, queryStr 2+ "%")
.setFirstResult((pageNo - 1) * pageSize)
.setMaxResults(pageSize)
.list();
结果还是
from UserPojo where uemail like ? and username like ?queryString: from UserPojo where uemail like ? and username like ?queryString: from UserPojo where uemail like ? and username like ?Hibernate: select userpojo0_.id as id2_, userpojo0_.uemail as uemail2_, userpojo0_.password as password2_, userpojo0_.username as username2_, userpojo0_.uage as uage2_, userpojo0_.sex as sex2_, userpojo0_.roleid as roleid2_ from user userpojo0_ where (userpojo0_.uemail like ?) and (userpojo0_.username like ?) limit ?Hibernate: select count(*) as col_0_0_ from user userpojo0_ where (userpojo0_.uemail like ?) and (userpojo0_.username like ?)我不知道那个limit是啥意思了
除了配置问题,对数据库设计有没有啥特殊的要求啊,求解释
别用Object 用它本身类型试试看。
除了用setParameter方法之外还有那么比较好用啊
语句的原型是
this.sql="from UserPojo where uemail like ? and username like ?";
this.objs=new Object[]{"%"+uemail+"%","%"+username+"%"};你这样不对,少单引号 this.objs=new Object[]{" ' %"+uemail+"% ' "," ' %"+username+"% ' "};
百分号两边要有单引号~
setParameter 是设置别名的一种形式,你的是?的型式 。
语句的原型是
this.sql="from UserPojo where uemail like ? and username like ?";
this.objs=new Object[]{"%"+uemail+"%","%"+username+"%"};你这样不对,少单引号 this.objs=new Object[]{" ' %"+uemail+"% ' "," ' %"+username+"% ' "};
百分号两边要有单引号~
试过了,不是这的错.