select top 3 * from doctors where docID not in(select top 3 docID from doctors)
这句SQL语句转换成HQL语句怎么写啊 ? 

解决方案 »

  1.   

    我的类名就是Doctors,但是你给的这行还是不行哦 
    好像在HQL里没有“*”的概念  所以不能用select top 3 *
      

  2.   

    我的类名就是Doctors,但是你给的这行还是不行哦 
    好像在HQL里没有“*”的概念  所以不能用select top 3 *
      

  3.   


    String sql = “from Doctors d where d.docID not in(select top 3 d.docID from Doctors d) ”
    Query query = session.createQuery( sql);
    query.setMaxResults(3);没有测试,楼主试下
      

  4.   

    还是不行哦 不过终于有点收获 就是query.setMaxResults(3);  Thank you
      

  5.   

    前后不用相同的别名?
    String sql = “from Doctors d where d.docID not in(select top 3 doc.docID from Doctors doc) ”
    Query query = session.createQuery( sql);
    query.setMaxResults(3);
    这样就行了 ?