// updates the order item status on how many delivered or not public Boolean updateOrderItemStatus(int orderitemId, String status) { Boolean flag = false; try { Session session1 = HibernateUtil.getSessionFactory().openSession(); Transaction tx1 = session1.beginTransaction(); OrderItem orderitem = (OrderItem) session1.get(OrderItem.class, orderitemId); orderitem.setItemStatus(status); session1.update(orderitem); flag = true; tx1.commit(); session1.close(); } catch (Exception e) { e.printStackTrace(); } return flag; }
// updates the details of an order item public void updateItem(String status, Float cost, int oid) { try { Session session1 = HibernateUtil.getSessionFactory().openSession(); Transaction tx1 = session1.beginTransaction(); OrderItem oi1 = (OrderItem) session1.get(OrderItem.class, oid); oi1.setItemStatus(status); Book book = oi1.getBook(); int bookId = book.getProductId(); Book book1 = (Book) session1.get(Book.class, bookId); session1.update(oi1); session1.update(book1); tx1.commit(); close(); } catch (Exception e) { e.printStackTrace(); } }