jpa如何使用hibernate的evict()方法

来源:互联网 发布:业主信息收集软件 编辑:程序博客网 时间:2024/06/05 16:54


当我们使用hibernate的时候,想将对象从持久状态转化为游离状态,这个时候我们可以使用evict()方法。

前些日子在使用jpa时候,需要使用到类似hibernate的evict()方法。

然后翻遍了api文档,也找不到类似hibernate的evict方法。

这时候只能求助于google。


hibernate官方论坛上看到这么一种方法可以解决:

A better solution!

( (HibernateEntityManagerFactory) emf).getSessionFactory()

and then the evict method you want
_________________

通过上面的转换,我们遍可以使用SessionFactory了。

呵呵。。于是问题也就可以解决了。
原创粉丝点击