Hibernate 4.0.0Final在哪里是SessionFactory.openSession(拦截器拦截器)

pin*_*awn 10 java hibernate

我尝试了一些来自hibernate 4.0拦截器的代码,它提供了使用会话级拦截器的代码:

Session session = sf.openSession( new AuditInterceptor() );
Run Code Online (Sandbox Code Playgroud)

但是,我检查了hibernate-core 4.0源代码和onlie hibernate 4.0 java-doc,该类SessionFactory没有方法openSession(Interceptor interceptor) ,但hibernate 3.6 java-doc确实有这个方法.

谁知道方法移动到哪里?如果弃用,为什么文档仍然保留在教程文档中?我应该如何在4.0中使用会话级拦截器?

axt*_*avt 26

它现在使用Builder模式实现:

Session session = sf.withOptions()
                    .interceptor(new AuditInterceptor())
                    .openSession(); 
Run Code Online (Sandbox Code Playgroud)

  • 跆拳道.为什么没有这个文件?你在哪里找到这个家伙,你是文件英雄 (5认同)
  • 并不是说我不同意文档不太理想,手册一般不提"这就是你习惯的方式,但现在你做......".这是变更日志和迁移指南的工作.更改日志(1)放入发行版下载包中,(2)在发布公告中引用,(3)通过Hibernate Jira永久提供.迁移指南列于https://community.jboss.org/wiki/Hibernate3MigrationGuides; 例如,https://community.jboss.org/wiki/HibernateCoreMigrationGuide40 (2认同)