2008-12-01 94 views

回答

2

一些集合函數的支持:看在manual

+0

不幸的是鏈接改變了。你能重新檢索頁面嗎?謝謝! – bluish 2010-12-21 09:45:52

+0

感謝您的提醒。固定鏈接 – 2011-01-01 16:45:25

5

這就是我如何在Hibernate中使用最多:

public long getNextId(){ 
long appId;   
try{ 
      Session session = HibernateUtil.getAdmSessionFactory().getCurrentSession(); 
      Transaction t = session.beginTransaction(); 
      String sequel = "Select max(JAdmAppExemptionId) from JAdmAppExemption"; 
      Query q = session.createQuery(sequel); 
      List currentSeq = q.list(); 
      if(currentSeq == null){ 
       return appId; 
      }else{ 
      appId = (Long)currentSeq.get(0); 
      return appId+1; 
      } 

     }catch(Exception exc){ 
      System.out.print("Unable to get latestID"); 
      exc.printStackTrace(); 

     } 
     return 0; 

    }