Skip to content

Commit f27d2dd

Browse files
committed
add two @implNotes
1 parent 8d9e639 commit f27d2dd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,16 @@
208208
* <p>
209209
* This class is not thread-safe.
210210
*
211+
* @implNote The {@code SessionImpl} does not directly perform operations against the database or second-level cache.
212+
* Instead, it is an {@link org.hibernate.event.spi.EventSource}, raising events which are processed by various
213+
* implementations of the listener interfaces defined by {@link org.hibernate.event.spi}. These listeners typically
214+
* place {@link org.hibernate.action.internal.EntityAction} instances on the {@link ActionQueue} associated with the
215+
* session, and such actions are executed asynchronously when the session is {@linkplain #flush flushed}. The
216+
* motivation behind this architecture is two-fold: first, it enables customization by sophisticated extensions to
217+
* Hibernate ORM, and, second, it enables the transactional write-behind semantics of a stateful session. The stateful
218+
* session holds its state in an instance of {@link StatefulPersistenceContext}, which we may view as the first-level
219+
* cache associated with the session.
220+
*
211221
* @author Gavin King
212222
* @author Steve Ebersole
213223
* @author Brett Meyer

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@
107107
* <p>
108108
* This class is not thread-safe.
109109
*
110+
* @implNote The {@code StatelessSessionImpl} is not an {@link org.hibernate.event.spi.EventSource} and does not
111+
* make use of the usual {@linkplain org.hibernate.event.spi eventing infrastructure} to implement persistence
112+
* operations. It does raise pre- and post- events for the benefit of integration, however. Since it performs all
113+
* operations synchronously, it does not maintain an {@link org.hibernate.engine.spi.ActionQueue}. Therefore, it
114+
* cannot, unfortunately, reuse the various {@link org.hibernate.action.internal.EntityAction} subtypes. This is
115+
* a pity, since it results in some code duplication. On the other hand, a {@code StatelessSession} is easier to
116+
* debug and understand. A {@code StatelessSession} does hold state in a long-lived {@link PersistenceContext},
117+
* but it does temporarily keep state within an instance of {@link StatefulPersistenceContext} while processing
118+
* the results of a given query.
119+
*
110120
* @author Gavin King
111121
* @author Steve Ebersole
112122
*/

0 commit comments

Comments
 (0)