hibernate4 执行存储过程
- 作者: 超神罗天征
- 来源: 51数据库
- 2021-01-02
例子
public void saveStoredProcedure(final String adminId, final String menuId, final String toolbars) {
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
SQLQuery sqlQuery = session.createSQLQuery("{call P_SaveOperatorPopedom(?,?,?)}");
sqlQuery.setString(0, adminId);
sqlQuery.setString(1, menuId);
sqlQuery.setString(2, toolbarsXML);
sqlQuery.executeUpdate();
return null;
}
});
}
重点是这个写法 session.createSQLQuery("{call P_SaveOperatorPopedom(?,?,?)}");
我这边用的是spring提供的HibernateDaoSupport
期待看到有用的回答!
public void saveStoredProcedure(final String adminId, final String menuId, final String toolbars) {
getHibernateTemplate().execute(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
SQLQuery sqlQuery = session.createSQLQuery("{call P_SaveOperatorPopedom(?,?,?)}");
sqlQuery.setString(0, adminId);
sqlQuery.setString(1, menuId);
sqlQuery.setString(2, toolbarsXML);
sqlQuery.executeUpdate();
return null;
}
});
}
重点是这个写法 session.createSQLQuery("{call P_SaveOperatorPopedom(?,?,?)}");
我这边用的是spring提供的HibernateDaoSupport
期待看到有用的回答!
推荐阅读
