通过spring的hibernate模板调用存储过程,直接传入存储过程的名字就可以:
-
/*
-
* 方便在job中调用存储过程
-
* 调用无参数的存储过程,传入存储过程名字
-
*/
-
public int callProcedure(final String procedureName)
-
{
-
int count = (Integer)this.getHibernateTemplate().execute(new HibernateCallback(){
-
public Object doInHibernate(Session session)throws HibernateException, SQLException {
-
String procedureSql = "{call "+ procedureName +"()}";
-
Query query = session.createSQLQuery(procedureSql);
-
Integer num = query.executeUpdate();
-
return num;
-
}
-
});
-
return count;
-
}
阅读(1951) | 评论(0) | 转发(0) |