以下陈述是否有效?
persist() also guarantees that it will not execute an INSERT statement if it is called outside of transaction boundaries
当我使用持久性尝试以下代码时;然后在没有任何事务的情况下插入该行(已注释掉)。
SessionFactory sessionFactory = new Configuration().configure("student.cfg.xml").buildSessionFactory();
Session session = sessionFactory.openSession();
//Transaction tran = session.beginTransaction();
/*
* Persist is working without transaction boundaries ===> why?
*/
Student student = new Student();
student.setFirstName("xxx");
student.setLastName("yyy");
student.setCity("zzz");
student.setState("ppp");
student.setCountry("@@@");
student.setId("123456");
session.persist(student);
//tran.commit();
session.flush();
session.close();