session = sessionFactory.openSession();
session.beginTransaction();
List result = session.createQuery("from Event").list();
for (Event event : (List<Event>) result) {
System.out.println("Event (" + event.getDate() + ") : " +
event.getTitle());
}
session.getTransaction().commit();
session.close();
爲什麼要進行session.getTransaction().commit()
即使在事件列表中只是被打印出來?
感謝您的詳細解答 –