baidu_29643173 2015-07-08 05:41 采纳率: 0%
浏览 4099

为什么按学号查询,查哪个学号都显示所有

public List getList(int xh)
{
String where="";
if(xh!=0)
{
where=where+" where xuehao="+xh+"";
}
return this.findAll(where);
}

下边是findAll方法
private List<Xuesheng>  findAll(String where)
{
       Session sess = this.getSessionFactory().openSession();
         try
         {
          Query query = sess.createQuery(" From  Xuesheng " + where + " order by id ");
          return query.list();
         }
         finally
         {
            sess.close();
         }
}
  • 写回答

15条回答 默认 最新

  • uptomepc16 2015-07-08 05:49
    关注

    那就是查询失败,你确定你的数据库字段是 xuehao ? 再确认下字段类型, 然后就是你的语句中 where xuehao = 后面的 “ 需要转译

    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建