diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 2b366cc15902..1feafbfa1126 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -208,6 +208,16 @@ *
* This class is not thread-safe. * + * @implNote The {@code SessionImpl} does not directly perform operations against the database or second-level cache. + * Instead, it is an {@link org.hibernate.event.spi.EventSource}, raising events which are processed by various + * implementations of the listener interfaces defined by {@link org.hibernate.event.spi}. These listeners typically + * place {@link org.hibernate.action.internal.EntityAction} instances on the {@link ActionQueue} associated with the + * session, and such actions are executed asynchronously when the session is {@linkplain #flush flushed}. The + * motivation behind this architecture is two-fold: first, it enables customization by sophisticated extensions to + * Hibernate ORM, and, second, it enables the transactional write-behind semantics of a stateful session. The stateful + * session holds its state in an instance of {@link StatefulPersistenceContext}, which we may view as the first-level + * cache associated with the session. + * * @author Gavin King * @author Steve Ebersole * @author Brett Meyer @@ -244,7 +254,6 @@ public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) { final DiagnosticEvent sessionOpenEvent = getEventMonitor().beginSessionOpenEvent(); try { - persistenceContext = createPersistenceContext(); actionQueue = createActionQueue(); @@ -341,7 +350,10 @@ protected void applyLockOptionsHint(SelectionQuery> query) { protected void applyQuerySettingsAndHints(Query> query) { applyQuerySettingsAndHints( (SelectionQuery>) query ); + applyLockTimeoutHint( query ); + } + private void applyLockTimeoutHint(Query> query) { final Integer specLockTimeout = LegacySpecHelper.getInteger( HINT_SPEC_LOCK_TIMEOUT, HINT_JAVAEE_LOCK_TIMEOUT, diff --git a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java index b7e1f75878b8..71c99970aa8b 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/StatelessSessionImpl.java @@ -107,6 +107,16 @@ *
* This class is not thread-safe. * + * @implNote The {@code StatelessSessionImpl} is not an {@link org.hibernate.event.spi.EventSource} and does not + * make use of the usual {@linkplain org.hibernate.event.spi eventing infrastructure} to implement persistence + * operations. It does raise pre- and post- events for the benefit of integration, however. Since it performs all + * operations synchronously, it does not maintain an {@link org.hibernate.engine.spi.ActionQueue}. Therefore, it + * cannot, unfortunately, reuse the various {@link org.hibernate.action.internal.EntityAction} subtypes. This is + * a pity, since it results in some code duplication. On the other hand, a {@code StatelessSession} is easier to + * debug and understand. A {@code StatelessSession} does hold state in a long-lived {@link PersistenceContext}, + * but it does temporarily keep state within an instance of {@link StatefulPersistenceContext} while processing + * the results of a given query. + * * @author Gavin King * @author Steve Ebersole */