Hibernate 调用JDBC执行存储过程

xiaoxiao2023-02-06  29

public boolean procMemberInfo(int userId, int order,int day) {  boolean flag = false;  Session session = null;  Transaction ts = null;  try {   session = HibernateSessionFactory.getSession();   ts = session.beginTransaction();   CallableStatement c = ((SessionImpl) session).getBatcher()     .prepareCallableStatement("{call MemberInfo_insert(?,?,?)}");   c.setInt(1, userId);   c.setShort(2, (short)order);   c.setInt(3, day);   int ret=c.executeUpdate();   if(ret>0){    flag = true;   }   ts.commit();   return flag;   } catch (Exception ex) {   // TODO: handle exception   ex.printStackTrace();   if(ts!=null){    ts.rollback();   }  }finally{   if(session !=null){    session.close();   }  }  return flag; }

转载请注明原文地址: https://www.6miu.com/read-4981385.html

最新回复(0)