少し古い質問ですが、正しく答えることを考えました。
プロパティ名hibernate.current_session_context_class
をに変更することにより、current_session_context_class
デフォルトを強制しますJTASessionContext
。
以下のスニペットは休止状態からのものSessionFactoryImpl
です。ところで、Environment.CURRENT_SESSION_CONTEXT_CLASS
です"hibernate.current_session_context_class"
。ThreadLocalSessionContext
この問題が発生します。
private CurrentSessionContext buildCurrentSessionContext() {
String impl = (String) properties.get( Environment.CURRENT_SESSION_CONTEXT_CLASS );
// for backward-compatibility
if ( impl == null ) {
if ( canAccessTransactionManager() ) {
impl = "jta";
}
else {
return null;
}
}
if ( "jta".equals( impl ) ) {
// if ( ! transactionFactory().compatibleWithJtaSynchronization() ) {
// LOG.autoFlushWillNotWork();
// }
return new JTASessionContext( this );
}
else if ( "thread".equals( impl ) ) {
return new ThreadLocalSessionContext( this );
}
else if ( "managed".equals( impl ) ) {
return new ManagedSessionContext( this );
}
else {
try {
Class implClass = serviceRegistry.getService( ClassLoaderService.class ).classForName( impl );
return (CurrentSessionContext)
implClass.getConstructor( new Class[] { SessionFactoryImplementor.class } )
.newInstance( this );
}
catch( Throwable t ) {
LOG.unableToConstructCurrentSessionContext( impl, t );
return null;
}
}
}
チェックしてくださいThreadLocalSessionContext.TransactionProtectionWrapper.invoke