Hibernate4 调用存储过程

Session se = hibernateBaseDAO.getSession();
  return se.doReturningWork(new ReturningWork<Integer>() {

   @Override
   public Integer execute(Connection con) throws SQLException {
    int result = 0 ;
    CallableStatement   cstmt   = con.prepareCall("{call pro_generate_glsxid(?,?,?,?)}");    
    cstmt.setString(1, type);
    cstmt.setInt(2, head);
    cstmt.registerOutParameter("i_idaccount", Types.INTEGER);
    cstmt.registerOutParameter("i_result", Types.INTEGER);
    cstmt.executeUpdate();
    result = cstmt.getInt("i_result") ; 
    int userId = cstmt.getInt("i_idaccount") ; 
    if(result==1)
    {
     return userId;
    }
    return null;
   }
  });

你可能感兴趣的:(Hibernate4)