jiguan北京 and departmentjsj and sex女????怎么没有=的jiguan='北京' and department='jsj' and sex='女'

解决方案 »

  1.   

    1楼说的是个原因. 还有 hql做模糊查询的时候最好用 参数的形式.
      

  2.   

    代码多难看呀,构建复杂查询为什么不用Criteria???
      

  3.   

    你这hql和我写的数据结构有的一拼了。
    ======================
    一句话,错的让人看不懂
      

  4.   

     String id = studentForm.getId(); 
    String nation = studentForm.getNation(); 
    String department = studentForm.getDepartment(); 
    String sex = studentForm.getSex(); 
    System.out.print("id="+id); // 组织hql语句 
    String hql = "from Student where 1=1"; 
    if (id != null && !id.equals("")) { 
    hql = hql + " and id=" + id; 

    if (nation != null && !nation.equals("")) { 
    hql = hql + " and jiguan=" + nation; 

    if (department != null && !department.equals("")) { 
    hql = hql + " and department=" + department; 

    if (sex != null && !sex.equals("")) { 
    hql = hql + " and sex=" + sex;