我们可以在Hibernate中再次创建Persistent对象Transient吗?

时间:2018-05-29 16:36:38

标签: hibernate session persistent

据我所知,Persistent对象在DB中有表示, 但如果我在该对象上调用session.delete(), 对象的状态是什么? Detached or Transient ?

考虑以下代码:

      Animal a = new Animal(1," Dolphin ", " Sea" ); 

      Session s= SessionFactoryUtil.getSession();
      Transaction  tr = s.beginTransaction();

         s.save(a);       
         s.flush();         //here a became persistent
         s.delete(a); 
         tr.commit();      // what is the state of a here ?
         s.close();

0 个答案:

没有答案