「Java開発」rollback()際にjava.lang.NullPointerException の対応サンプル

javaコード
public static void main(String[] args) {
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction trans = null;
try {
trans = session.beginTransaction();
Address obj = new Address(“Test", “OOSAKA", “YUFU", “12345");
Employee employee = new Employee(“yamada", obj);
session.save(employee);
trans.commit();
} catch (HibernateException e) {
if (trans != null) {
trans.rollback();
}
e.printStackTrace();
} finally {
session.close();
}

Java

Posted by arkgame