public boolean updateOrder(OrderBean order) { session = HibernateUtil.getSessionFactory().openSession(); try { transaction = session.beginTransaction(); session.update(order); transaction.commit(); } catch (Exception e) { transaction.rollback(); } finally { session.close(); } return true; }
public List<OrderBean> getAllOrder() { session = HibernateUtil.getSessionFactory().openSession(); try { String sql = "FROM OrderBean"; Query query = session.createQuery(sql); listOrder = query.list(); } catch (HandlerException e) { e.printStackTrace(); } finally { session.close(); } return listOrder; }
public boolean addOrder(OrderBean order) { session = HibernateUtil.getSessionFactory().openSession(); try { transaction = session.beginTransaction(); session.save(order); transaction.commit(); } catch (Exception e) { e.printStackTrace(); return false; } finally { session.close(); } return true; }