public void testSave() { User user = new User(); user.setName("apple"); user.setPassword("123456"); Session session = HibernateUtil.getSessionFactory().openSession(); Transaction tx = session.beginTransaction(); session.save(user); tx.commit(); session.close(); HibernateUtil.shutdown(); }
public void shutdown() { session.close(); HibernateUtil.shutdown(); }
/** Implement Two CRUD for add and delete */ public MessageCRUD() { session = HibernateUtil.getSessionFactory().openSession(); }