public String CreateCustomer(CustomerDaoBean newCustomer) throws Exception { String customerId = generateCustomerId(); newCustomer.setCustomerId(customerId); Session session = null; try { session = sessionFactory.openSession(); session.beginTransaction(); session.saveOrUpdate(newCustomer); session.getTransaction().commit(); } finally { if (session != null) { session.close(); } } return newCustomer.getCustomerId(); }
public String UpdateCustomer(CustomerDaoBean updatedCustomer) throws Exception { Session session = null; try { session = sessionFactory.openSession(); session.beginTransaction(); session.saveOrUpdate(updatedCustomer); session.getTransaction().commit(); } finally { if (session != null) { session.close(); } } return updatedCustomer.getCustomerId(); }