错误代码如
org.hibernate.TransactionException: nested transactions not supported
at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152)
at org.hibernate.internal.SessionImpl.beginTransaction(SessionImpl.java:1426)
at roseindia.PersonDetail.main(PersonDetail.java:16)
这是我的代码
Session session = HibernateUtil.getSessionFactory().openSession();
session.beginTransaction();
Person person = new Person();
System.out.println("Inserting Record");
session.beginTransaction();
person.setId(1);
person.setName("Jeff");
session.save(person);
session.getTransaction().commit();
System.out.println("Done");
session.close();
在提交旧交易之前,我没有开始交易。
发生了什么?