如果只是想纯粹的得到第二条数据 这样就可以了
String hql="from joinwork.workitem_history j order by updatedate desc "List l=sessin.createQuery(hql).setFirstResult(1).setMaxResult(1).list;l.get(0)就是你所要的记录

解决方案 »

  1.   

    可能是没有说清除吧 要最新的记录 
     相同的 activityid  取updatedate 最大的一条
      

  2.   

    select t1 from WorkHistory t1,WorkHistory t2 where t1.caseid = t2.caseid and t1.id <> t2.id
    and t1.updatedate = (select max(t3.updatedate) from WorkHistory t3)
      

  3.   

    sql语句我会
    select * FROM joinwork.workitem_history as t where not exists(select 1 from joinwork.workitem_history where activityid = t.activityid and updatedate > t.updatedate) and t.caseid='12'  
     这个就可以了现在是需要hql语句