Hibernate中取序列

Hibernate中取序列

Session session=HibernateSessionFactory.currentSession();
   Transaction tx=session.beginTransaction();
  
     Long s=(Long)session.createSQLQuery("select SQU_TEST.nextval as id from dual")
                      .addScalar("id",Hibernate.LONG)
                      .uniqueResult();                      
     tx.commit();  
   HibernateSessionFactory.closeSession();
System.out.println(s);

你可能感兴趣的:(Hibernate)