Hibernate 4.0.0Final在哪里,SessionFactory.openSession(拦截器拦截器) [英] Hibernate 4.0.0Final where is the SessionFactory.openSession(Interceptor interceptor)

查看:72
本文介绍了Hibernate 4.0.0Final在哪里,SessionFactory.openSession(拦截器拦截器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了 hibernate 4.0拦截器,该代码提供了用于会话级拦截器的代码:

I try some code from hibernate 4.0 interceptors, which gives this code for use session-level interceptors:

Session session = sf.openSession( new AuditInterceptor() );

但是,我同时检查了hibernate-core 4.0源代码和onlie hibernate 4.0 java-doc ,类SessionFactory没有方法openSession(Interceptor interceptor) ,但是

however, I check both the hibernate-core 4.0 source code and onlie hibernate 4.0 java-doc, the class SessionFactory does not have method openSession(Interceptor interceptor) , but hibernate 3.6 java-doc do have this method.

任何人都知道该方法将移至何处?如果已弃用,为什么文档仍将其保留在教程文档中?以及如何在4.0中使用会话级拦截器?

anyone knows where is the method move to? if deprecated, why the document still keeps it in tutorial document? and how should I use session-level interceptor in 4.0?

推荐答案

现在已使用Builder模式实现:

It's implemented using Builder pattern now:

Session session = sf.withOptions()
                    .interceptor(new AuditInterceptor())
                    .openSession(); 

这篇关于Hibernate 4.0.0Final在哪里,SessionFactory.openSession(拦截器拦截器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆