File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
src/main/java/net/netshot/netshot/database Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 98
98
import org .hibernate .HibernateException ;
99
99
import org .hibernate .Session ;
100
100
import org .hibernate .SessionFactory ;
101
+ import org .hibernate .StatelessSession ;
101
102
import org .hibernate .boot .Metadata ;
102
103
import org .hibernate .boot .MetadataSources ;
103
104
import org .hibernate .boot .SessionFactoryBuilder ;
@@ -416,14 +417,31 @@ public static Session getSession() throws HibernateException {
416
417
}
417
418
418
419
/**
419
- * Gets the session.
420
+ * Gets a database session.
420
421
*
422
+ * @param readOnly = true when requesting a read-only session
421
423
* @return the session
422
424
* @throws HibernateException the hibernate exception
423
425
*/
424
426
public static Session getSession (boolean readOnly ) throws HibernateException {
425
- return sessionFactory .withOptions ().tenantIdentifier (
426
- readOnly ? TenantIdentifier .READ_ONLY : TenantIdentifier .READ_WRITE ).openSession ();
427
+ return sessionFactory
428
+ .withOptions ()
429
+ .tenantIdentifier (
430
+ readOnly ? TenantIdentifier .READ_ONLY : TenantIdentifier .READ_WRITE )
431
+ .openSession ();
432
+ }
433
+
434
+ /**
435
+ * Gets a stateless database session.
436
+ *
437
+ * @return the session
438
+ * @throws HibernateException the hibernate exception
439
+ */
440
+ public static StatelessSession getStalessSession () throws HibernateException {
441
+ return sessionFactory
442
+ .withStatelessOptions ()
443
+ .tenantIdentifier (TenantIdentifier .READ_ONLY )
444
+ .openStatelessSession ();
427
445
}
428
446
429
447
/**
You can’t perform that action at this time.
0 commit comments