Skip to content

Commit 8a93c9e

Browse files
committed
add a comment explaining something rather subtle about session closure
1 parent 21f32e9 commit 8a93c9e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,16 @@ public void closeWithoutOpenChecks() {
395395
checkSessionFactoryOpen();
396396
checkOpenOrWaitingForAutoClose();
397397
if ( getSessionFactoryOptions().isReleaseResourcesOnCloseEnabled()
398-
|| !isTransactionInProgressAndNotMarkedForRollback() ) {
398+
|| !isTransactionInProgressAndNotMarkedForRollback() ) {
399399
super.close();
400400
}
401401
else {
402-
//Otherwise, session auto-close will be enabled by shouldAutoCloseSession().
402+
// In the JPA bootstrap, if the session is closed
403+
// before the transaction commits, we just mark the
404+
// session as closed, and set waitingForAutoClose.
405+
// This method will be called a second time from
406+
// afterTransactionCompletion when the transaction
407+
// commits, and the session will be closed for real.
403408
prepareForAutoClose();
404409
}
405410
}

0 commit comments

Comments
 (0)