public List findobjectList(String sql)
{
//Session s=this.getHibernateTemplate().getSessionFactory().openSession();
Session s=this.getSession();
List list= s.createSQLQuery(sql).list();
releaseSession(s);
return list;
}select distinct cl.classesName,s.studentsNumber ,s.studentsName,aa.scoresNo,an.answersscore ,cd.count,kk.count from users u right join students s on s.studentsUserId=u.usersId right join classes cl on s.classesId=cl.classesId left join courses c on cl.coursesid=c.coursesid left join academicyears a on c.academicyearsId=a.academicyearsId left join ( select sc.scoresNo,s.studentsId studentsId from students s,scores sc,scoreCatygorys scc where sc.studentsId=s.studentsId and sc.scoreCategorysId=scc.scoreCategorysId and scc.scoreCategoryName='期末成绩' ) aa on s.studentsId=aa.studentsId left join (select count(*) count,s.studentsId studentsId from attendances a,students s,users u where a.studentsId=s.studentsId and s.studentsUserId=u.usersId and a.attendancesqk='旷课') kk on s.studentsId=kk.studentsId left join answers an on an.studentsId=s.studentsId left join (select count(*) count,s.studentsId studentsId from attendances a,students s,users u where a.studentsId=s.studentsId and s.studentsUserId=u.usersId and a.attendancesqk='迟到' ) cd on s.studentsId=cd.studentsId where a.usersId=2
这是sql语句!不知道是不是sql出问题了,还是哪里出问题了
{
//Session s=this.getHibernateTemplate().getSessionFactory().openSession();
Session s=this.getSession();
List list= s.createSQLQuery(sql).list();
releaseSession(s);
return list;
}select distinct cl.classesName,s.studentsNumber ,s.studentsName,aa.scoresNo,an.answersscore ,cd.count,kk.count from users u right join students s on s.studentsUserId=u.usersId right join classes cl on s.classesId=cl.classesId left join courses c on cl.coursesid=c.coursesid left join academicyears a on c.academicyearsId=a.academicyearsId left join ( select sc.scoresNo,s.studentsId studentsId from students s,scores sc,scoreCatygorys scc where sc.studentsId=s.studentsId and sc.scoreCategorysId=scc.scoreCategorysId and scc.scoreCategoryName='期末成绩' ) aa on s.studentsId=aa.studentsId left join (select count(*) count,s.studentsId studentsId from attendances a,students s,users u where a.studentsId=s.studentsId and s.studentsUserId=u.usersId and a.attendancesqk='旷课') kk on s.studentsId=kk.studentsId left join answers an on an.studentsId=s.studentsId left join (select count(*) count,s.studentsId studentsId from attendances a,students s,users u where a.studentsId=s.studentsId and s.studentsUserId=u.usersId and a.attendancesqk='迟到' ) cd on s.studentsId=cd.studentsId where a.usersId=2
这是sql语句!不知道是不是sql出问题了,还是哪里出问题了
解决方案 »
- 求高手帮忙搞定java自动登陆功能
- 菜鸟碰到了老问题 多输入条件的查询
- 请问:地址栏的域名变成IP了,如何解决?
- 关于网页插件开发问题,在线请教?
- 请教 错误提示The Network Adapter could not establish the connection
- tomcat5.0+MS Access数据库连接问题连接问题。。解决问题就结贴。谢谢
- 热烈庆祝,个人网站终于完成(以struts框架),欢迎来测试
- 如何在局域网中,通过代理访问internet上的smtp服务器?
- 轻松得分,你还等什么?
- 求助:tomcat ip访问。
- 求解决方法 hibernate出错 调不通 望高手给力
- 解析字符串,大家尝试下
一个一个的加,排查另,这样的SQL很不合理,竟然用到3个子查询,建议优化一下