@@ -227,7 +227,19 @@ public interface SessionFactory extends EntityManagerFactory, Referenceable, Ser
227
227
StatelessSession openStatelessSession (Connection connection );
228
228
229
229
/**
230
- * Open a {@link Session} and use it to perform an action.
230
+ * Open a {@link Session} and use it to perform the given action.
231
+ *
232
+ * @apiNote This method does not begin a transaction, and so
233
+ * the session is not automatically flushed before the method
234
+ * returns unless either:
235
+ * <ul>
236
+ * <li>the given action calls {@link Session#flush() flush()}
237
+ * explicitly, or
238
+ * <li>a transaction is initiated by the given action, using
239
+ * {@link Session#inTransaction}, for example.
240
+ * </ul>
241
+ *
242
+ * @see #inTransaction(Consumer)
231
243
*/
232
244
default void inSession (Consumer <? super Session > action ) {
233
245
try ( Session session = openSession () ) {
@@ -236,7 +248,20 @@ default void inSession(Consumer<? super Session> action) {
236
248
}
237
249
238
250
/**
239
- * Open a {@link StatelessSession} and use it to perform an action.
251
+ * Open a {@link StatelessSession} and use it to perform the
252
+ * given action.
253
+ *
254
+ * @apiNote This method does not begin a transaction, and so
255
+ * the session is not automatically flushed before the method
256
+ * returns unless either:
257
+ * <ul>
258
+ * <li>the given action calls {@link Session#flush() flush()}
259
+ * explicitly, or
260
+ * <li>a transaction is initiated by the given action, using
261
+ * {@link Session#inTransaction}, for example.
262
+ * </ul>
263
+ *
264
+ * @see #inStatelessTransaction(Consumer)
240
265
*
241
266
* @since 6.3
242
267
*/
@@ -247,7 +272,7 @@ default void inStatelessSession(Consumer<? super StatelessSession> action) {
247
272
}
248
273
249
274
/**
250
- * Open a {@link Session} and use it to perform an action
275
+ * Open a {@link Session} and use it to perform the given action
251
276
* within the bounds of a transaction.
252
277
*
253
278
* @apiNote This method competes with the JPA-defined method
@@ -269,6 +294,18 @@ default void inStatelessTransaction(Consumer<? super StatelessSession> action) {
269
294
270
295
/**
271
296
* Open a {@link Session} and use it to obtain a value.
297
+ *
298
+ * @apiNote This method does not begin a transaction, and so
299
+ * the session is not automatically flushed before the method
300
+ * returns unless either:
301
+ * <ul>
302
+ * <li>the given action calls {@link Session#flush() flush()}
303
+ * explicitly, or
304
+ * <li>a transaction is initiated by the given action, using
305
+ * {@link Session#inTransaction}, for example.
306
+ * </ul>
307
+ *
308
+ * @see #fromTransaction(Function)
272
309
*/
273
310
default <R > R fromSession (Function <? super Session ,R > action ) {
274
311
try ( Session session = openSession () ) {
@@ -279,6 +316,18 @@ default <R> R fromSession(Function<? super Session,R> action) {
279
316
/**
280
317
* Open a {@link StatelessSession} and use it to obtain a value.
281
318
*
319
+ * @apiNote This method does not begin a transaction, and so
320
+ * the session is not automatically flushed before the method
321
+ * returns unless either:
322
+ * <ul>
323
+ * <li>the given action calls {@link Session#flush() flush()}
324
+ * explicitly, or
325
+ * <li>a transaction is initiated by the given action, using
326
+ * {@link Session#inTransaction}, for example.
327
+ * </ul>
328
+ *
329
+ * @see #fromStatelessTransaction(Function)
330
+ *
282
331
* @since 6.3
283
332
*/
284
333
default <R > R fromStatelessSession (Function <? super StatelessSession ,R > action ) {
0 commit comments