List<Userservices> list=new ArrayList<Userservices>();
Object[] object=new Object[5];
int i=0;
String hql="from Userservices u where 1=1";
if (name.trim().length()!=0) {
hql+=" and u.users.name=?";
object[i++]=name;
}
if (loginname.trim().length()!=0) {
hql+=" and u.loginname=?";
object[i++]=loginname;
}
if (labip.trim().length()!=0) {
hql+=" and u.labip=?";
object[i++]=labip;
}
if (status==-1) {
hql+=" and u.status in (?,?)";
object[i++]=0;
object[i++]=1;
}else {
hql+=" and u.status=?";
object[i++]=status;
}
list=this.getHibernateTemplate().find(hql, object);
System.out.println("==========================findByCond===============222=======count =====resultNum====");
return list;
出现下面的财务 我输入的是 name=lala ,status=-1
Positional parameter does not exist: 3 in query: from Userservices u where 1=1 and u.users.name=? and u.status in (?,?)
这是为什么?拼hql语句错了吗?
Object[] object=new Object[5];
int i=0;
String hql="from Userservices u where 1=1";
if (name.trim().length()!=0) {
hql+=" and u.users.name=?";
object[i++]=name;
}
if (loginname.trim().length()!=0) {
hql+=" and u.loginname=?";
object[i++]=loginname;
}
if (labip.trim().length()!=0) {
hql+=" and u.labip=?";
object[i++]=labip;
}
if (status==-1) {
hql+=" and u.status in (?,?)";
object[i++]=0;
object[i++]=1;
}else {
hql+=" and u.status=?";
object[i++]=status;
}
list=this.getHibernateTemplate().find(hql, object);
System.out.println("==========================findByCond===============222=======count =====resultNum====");
return list;
出现下面的财务 我输入的是 name=lala ,status=-1
Positional parameter does not exist: 3 in query: from Userservices u where 1=1 and u.users.name=? and u.status in (?,?)
这是为什么?拼hql语句错了吗?
估计是这个问题了,可以嵌套对象的吗?
我还没试过~~
参数不对!