Hibernate调用执行存储过程

Posted on 2013-04-18 13:46  IT_louis  阅读(290)  评论(0编辑  收藏  举报
 1 public UserInfo getUpdateUser(String userid) throws Exception {
 2   
 3   
 4   
 5    getHibernateTemplate().execute(new HibernateCallback() {
 6       public Object doInHibernate(Session session)
 7        throws HibernateException, SQLException {
 8           String hql = "{call demo001(?,?)}";
 9           session.flush();
10           CallableStatement casm=session.connection().prepareCall(hql);
11           System.out.println("----------DaoIMpl----------");
12           casm.setString(1, "滕州市");//设置参数值
13           casm.setString(2, "C017103216");
14 //          casm.setString(3, age);
15           boolean blm=casm.execute();
16 //          ResultSet rs= casm.executeQuery();
17 //          int i=0;
18 //          while(rs.next()){
19 //           System.out.println("第"+i+"条数据");
20 //           i++;
21 //          }
22           System.out.println("------res------"+blm);
23           return null;
24       }
25      });
26 //  Session s = sessionFactory.getCurrentSession();
27 //  s.beginTransaction();
28 //  UserInfo userinfo=(UserInfo)s.get(UserInfo.class, userid);
29 //  CallableStatement cstmt = hibernateTemplate.getSessionFactory().getCurrentSession().connection().prepareCall("{exec demo}"); 
30 //
31 //  cstmt.executeUpdate(); 
32 //  s.beginTransaction().commit();
33 //  
34 //  return userinfo;
35   return null;
36  }

 

Copyright © 2024 IT_louis
Powered by .NET 9.0 on Kubernetes