public class OpenSessionInterceptor extends ObjectSE implements MethodInterceptor, InitializingBean
Session
をバインドする単純な AOP Alliance MethodInterceptor
実装(以前にバインドされていない場合)。 これは、MVC セットアップではなく AOP セットアップで使用するための、OpenSessionInViewInterceptor
のラインに沿った単純な Hibernate セッションスコーピングインターセプターです。トランザクションに参加している場合を除いて、セッションは読み取り専用であるため、フラッシュモード "MANUAL" で新しい Session
を開きます。
OpenSessionInViewInterceptor
, OpenSessionInViewFilter
, HibernateTransactionManager
, TransactionSynchronizationManager
, SessionFactory.getCurrentSession()
コンストラクターと説明 |
---|
OpenSessionInterceptor() |
修飾子と型 | メソッドと説明 |
---|---|
void | afterPropertiesSet() |
SessionFactory | getSessionFactory() Hibernate セッションの作成に使用する Hibernate SessionFactory を返します。 |
ObjectSE | invoke(MethodInvocation invocation) このメソッドを実装して、呼び出しの前後に追加の処理を実行します。 |
protected Session | openSession() 使用すべきではありません。 5.0 現在、 openSession(SessionFactory) を推奨 |
protected Session | openSession(SessionFactory sessionFactory) 指定された SessionFactory のセッションを開きます。 |
void | setSessionFactory(SessionFactory sessionFactory) Hibernate セッションの作成に使用する Hibernate SessionFactory を設定します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSE
public void setSessionFactory(@Nullable SessionFactory sessionFactory)
@Nullable public SessionFactory getSessionFactory()
public void afterPropertiesSet()
InitializingBean
BeanFactoryAware
、ApplicationContextAware
などを満たした後、包含 BeanFactory
によって呼び出されます。このメソッドにより、Bean インスタンスは、すべての Bean プロパティが設定されたときに、その全体的な構成の検証と最終的な初期化を実行できます。
InitializingBean
の afterPropertiesSet
public ObjectSE invoke(MethodInvocation invocation) throws ThrowableSE
MethodInterceptor
Joinpoint.proceed()
を呼び出すようにします。MethodInterceptor
の invoke
invocation
- メソッド呼び出しジョインポイント Joinpoint.proceed()
の呼び出しの結果。インターセプターによってインターセプトされる可能性があります ThrowableSE
- インターセプターまたはターゲットオブジェクトが例外をスローする場合 protected Session openSession(SessionFactory sessionFactory) throws DataAccessResourceFailureException
デフォルトの実装は SessionFactory.openSession()
メソッドに委譲し、Session
のフラッシュモードを "MANUAL" に設定します。
sessionFactory
- 使用する SessionFactoryDataAccessResourceFailureException
- セッションを作成できなかった場合 FlushMode.MANUAL
@DeprecatedSE @Nullable protected Session openSession() throws DataAccessResourceFailureException
openSession(SessionFactory)
に置き換えられました。