把成绩作为主表设置多对一的关联关系,from 成绩 where 成绩>=60 and 成绩<=70 and 成绩.学生.入学时间='2005' 

解决方案 »

  1.   

    如果不是动态拼接的话,可以这么写             Query query = session.createQuery("select s from Student S " +
                 "inner join fetch s.Results r " +
                 "where s.inYear= :inyear and r.chengji>=:chengjiS and r.chengji<=:chengjiE").
                 setInteger("inYear", 2005).setInteger("chengjiS", 60).setInteger("chengjiE", 70);
                 List list = query.list();
      

  2.   

    hql = "from Result r where r.score<70 and r.score>60 and r.student.enterTime>='2005-1-1' and  r.student.enterTime<'2006-1-1'" ;其中字段名可以根据lz的实际情况更改。