Hibernate 调用存储过程

方法一:
List<?> list = new ArrayList<HibernateProcedureObject>();
try {
session = getCurrentSession(entityClass);
SQLQuery query = session.createSQLQuery(procedure);
query.setString(0, requestId);
list = query.list();
} catch (HibernateException e) {
e.printStackTrace();
logger.log(RMTManagementLevel.ERROR, e);
} finally {
this.closeConnection();
}
return list;

SQLQuery query=this.getSession().createSQLQuery("{call procName(?,?,?)}");
query.setString(0,x);
query.setString(1,xxx);
query.setString(2,xxxx);
List list = query.list();

方法二:
Session session =HibernateSessionFactory.getSession();  
Connection conn = session.connection();  
ResultSet rs =null;  
CallableStatement call = conn.prepareCall("{Call proc()}");  
rs = call.executeQuery();  
rs.close();  
session.close(); 

你可能感兴趣的:(Hibernate,Sybase,procedure)