1
考慮一個假設的場景,是否有一種方法可以在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?