考虑一个假设的场景,hibernate 有没有办法使持久实体瞬态但同时不删除数据库中的行?
session.delete()
会使其暂时化,但同时会为数据库发出删除 SQL。
//Persistant context started...
Session session2 = HibernateUtils.sessionFactory.openSession();
session2.beginTransaction();
Admin admin = (Admin) session2.load(Admin.class, 1L);
session2.delete(admin);
session2.getTransaction().commit();
session2.close();
//Persistant context ended...
...
//admin now is transient but the row has been deleted, can we stop this?