コード例 #1
0
 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();
 }
コード例 #2
0
 public void shutdown() {
   session.close();
   HibernateUtil.shutdown();
 }
コード例 #3
0
 /** Implement Two CRUD for add and delete */
 public MessageCRUD() {
   session = HibernateUtil.getSessionFactory().openSession();
 }