3535 * and so an operation performed via a stateless session never cascades to
3636 * associated instances.
3737 * <p>
38+ * The basic operations of a stateless session are {@link #get(Class, Object)},
39+ * {@link #insert(Object)}, {@link #update(Object)}, {@link #delete(Object)},
40+ * and {@link #upsert(Object)}. These operations are always performed
41+ * synchronously, resulting in immediate access to the database. Notice that
42+ * update is an explicit operation. There is no "flush" operation for a
43+ * stateless session, and so modifications to entities are never automatically
44+ * detected and made persistent.
45+ * <p>
46+ * Similarly, lazy association fetching is an explicit operation. A collection
47+ * or proxy may be fetched by calling {@link #fetch(Object)}.
48+ * <p>
3849 * Stateless sessions are vulnerable to data aliasing effects, due to the
3950 * lack of a first-level cache.
4051 * <p>
4152 * On the other hand, for certain kinds of transactions, a stateless session
4253 * may perform slightly faster than a stateful session.
54+ * <p>
55+ * Certain rules applying to stateful sessions are relaxed in a stateless
56+ * session:
57+ * <ul>
58+ * <li>it is not necessary to discard a session and its entities after an
59+ * exception is thrown by a stateless sessions, and
60+ * <li>when an exception is thrown by a stateless session, the current
61+ * transaction is not automatically marked for rollback.
62+ * </ul>
4363 *
4464 * @author Gavin King
4565 */
@@ -50,7 +70,10 @@ public interface StatelessSession extends SharedSessionContract {
5070void close ();
5171
5272/**
53- * Insert a row.
73+ * Insert a record.
74+ * <p>
75+ * The {@link jakarta.persistence.PostPersist} callback will be
76+ * triggered if the operation is successful.
5477 *
5578 * @param entity a new transient instance
5679 *
@@ -59,7 +82,10 @@ public interface StatelessSession extends SharedSessionContract {
5982Object insert (Object entity );
6083
6184/**
62- * Insert a row.
85+ * Insert a record.
86+ * <p>
87+ * The {@link jakarta.persistence.PostPersist} callback will be
88+ * triggered if the operation is successful.
6389 *
6490 * @param entityName The entityName for the entity to be inserted
6591 * @param entity a new transient instance
@@ -69,29 +95,41 @@ public interface StatelessSession extends SharedSessionContract {
6995Object insert (String entityName , Object entity );
7096
7197/**
72- * Update a row.
98+ * Update a record.
99+ * <p>
100+ * The {@link jakarta.persistence.PostUpdate} callback will be
101+ * triggered if the operation is successful.
73102 *
74103 * @param entity a detached entity instance
75104 */
76105void update (Object entity );
77106
78107/**
79- * Update a row.
108+ * Update a record.
109+ * <p>
110+ * The {@link jakarta.persistence.PostUpdate} callback will be
111+ * triggered if the operation is successful.
80112 *
81113 * @param entityName The entityName for the entity to be updated
82114 * @param entity a detached entity instance
83115 */
84116void update (String entityName , Object entity );
85117
86118/**
87- * Delete a row.
119+ * Delete a record.
120+ * <p>
121+ * The {@link jakarta.persistence.PostRemove} callback will be
122+ * triggered if the operation is successful.
88123 *
89124 * @param entity a detached entity instance
90125 */
91126void delete (Object entity );
92127
93128/**
94- * Delete a row.
129+ * Delete a record.
130+ * <p>
131+ * The {@link jakarta.persistence.PostRemove} callback will be
132+ * triggered if the operation is successful.
95133 *
96134 * @param entityName The entityName for the entity to be deleted
97135 * @param entity a detached entity instance
@@ -122,7 +160,7 @@ public interface StatelessSession extends SharedSessionContract {
122160void upsert (String entityName , Object entity );
123161
124162/**
125- * Retrieve a row .
163+ * Retrieve a record .
126164 *
127165 * @param entityName The name of the entity to retrieve
128166 * @param id The id of the entity to retrieve
@@ -132,7 +170,7 @@ public interface StatelessSession extends SharedSessionContract {
132170Object get (String entityName , Object id );
133171
134172/**
135- * Retrieve a row .
173+ * Retrieve a record .
136174 *
137175 * @param entityClass The class of the entity to retrieve
138176 * @param id The id of the entity to retrieve
@@ -142,7 +180,7 @@ public interface StatelessSession extends SharedSessionContract {
142180<T > T get (Class <T > entityClass , Object id );
143181
144182/**
145- * Retrieve a row , obtaining the specified lock mode.
183+ * Retrieve a record , obtaining the specified lock mode.
146184 *
147185 * @param entityName The name of the entity to retrieve
148186 * @param id The id of the entity to retrieve
@@ -153,7 +191,7 @@ public interface StatelessSession extends SharedSessionContract {
153191Object get (String entityName , Object id , LockMode lockMode );
154192
155193/**
156- * Retrieve a row , obtaining the specified lock mode.
194+ * Retrieve a record , obtaining the specified lock mode.
157195 *
158196 * @param entityClass The class of the entity to retrieve
159197 * @param id The id of the entity to retrieve
@@ -164,7 +202,7 @@ public interface StatelessSession extends SharedSessionContract {
164202<T > T get (Class <T > entityClass , Object id , LockMode lockMode );
165203
166204/**
167- * Retrieve a row , fetching associations specified by the
205+ * Retrieve a record , fetching associations specified by the
168206 * given {@link EntityGraph}.
169207 *
170208 * @param graph The {@link EntityGraph}
@@ -179,7 +217,7 @@ public interface StatelessSession extends SharedSessionContract {
179217<T > T get (EntityGraph <T > graph , GraphSemantic graphSemantic , Object id );
180218
181219/**
182- * Retrieve a row , fetching associations specified by the
220+ * Retrieve a record , fetching associations specified by the
183221 * given {@link EntityGraph}, and obtaining the specified
184222 * lock mode.
185223 *
@@ -228,7 +266,7 @@ public interface StatelessSession extends SharedSessionContract {
228266void refresh (String entityName , Object entity , LockMode lockMode );
229267
230268/**
231- * Fetch an association that's configured for lazy loading.
269+ * Fetch an association or collection that's configured for lazy loading.
232270 * <p>
233271 * Warning: this operation in a stateless session is quite sensitive
234272 * to data aliasing effects and should be used with great care.
0 commit comments