36
36
import org .hibernate .engine .spi .SessionFactoryImplementor ;
37
37
import org .hibernate .engine .spi .SessionImplementor ;
38
38
import org .hibernate .internal .build .AllowSysOut ;
39
- import org .hibernate .internal .util .PropertiesHelper ;
40
39
import org .hibernate .internal .util .ReflectHelper ;
41
40
import org .hibernate .internal .util .StringHelper ;
42
41
import org .hibernate .internal .util .config .ConfigurationHelper ;
@@ -109,7 +108,6 @@ protected Session openSession(Interceptor interceptor) throws HibernateException
109
108
// before/after test class ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110
109
111
110
@ BeforeClassOnce
112
- @ SuppressWarnings ( {"UnusedDeclaration" })
113
111
protected void buildSessionFactory () {
114
112
buildSessionFactory ( null );
115
113
}
@@ -384,7 +382,8 @@ protected void prepareTest() throws Exception {
384
382
public final void afterTest () throws Exception {
385
383
// see https://github.com/hibernate/hibernate-orm/pull/3412#issuecomment-678338398
386
384
if ( getDialect () instanceof H2Dialect ) {
387
- ReflectHelper .getMethod ( Class .forName ( "org.h2.util.DateTimeUtils" ), "resetCalendar" ).invoke ( null );
385
+ ReflectHelper .getMethod ( Class .forName ( "org.h2.util.DateTimeUtils" ), "resetCalendar" )
386
+ .invoke ( null );
388
387
}
389
388
390
389
completeStrayTransaction ();
@@ -449,7 +448,7 @@ protected void cleanupTestData() throws Exception {
449
448
// Because of https://hibernate.atlassian.net/browse/HHH-5529,
450
449
// we can't rely on a Bulk Delete query which will not clear the link tables in @ElementCollection or unidirectional collections
451
450
doInHibernate ( this ::sessionFactory , s -> {
452
- s .createQuery ( "from java.lang.Object" ).list ().forEach ( s ::remove );
451
+ s .createQuery ( "from java.lang.Object" , Object . class ).list ().forEach ( s ::remove );
453
452
} );
454
453
}
455
454
}
@@ -472,7 +471,6 @@ public void execute(Connection connection) throws SQLException {
472
471
protected void cleanupTest () throws Exception {
473
472
}
474
473
475
- @ SuppressWarnings ( {"UnnecessaryBoxing" , "UnnecessaryUnboxing" })
476
474
@ AllowSysOut
477
475
protected void assertAllDataRemoved () {
478
476
if ( !createSchema () ) {
@@ -486,9 +484,9 @@ protected void assertAllDataRemoved() {
486
484
Transaction transaction = tmpSession .beginTransaction ();
487
485
try {
488
486
489
- List list = tmpSession .createQuery ( "select o from java.lang.Object o" ).list ();
487
+ List <?> list = tmpSession .createQuery ( "select o from java.lang.Object o" ).list ();
490
488
491
- Map <String ,Integer > items = new HashMap <String , Integer >();
489
+ Map <String ,Integer > items = new HashMap <>();
492
490
if ( !list .isEmpty () ) {
493
491
for ( Object element : list ) {
494
492
Integer l = items .get ( tmpSession .getEntityName ( element ) );
@@ -500,7 +498,7 @@ protected void assertAllDataRemoved() {
500
498
System .out .println ( "Data left: " + element );
501
499
}
502
500
transaction .rollback ();
503
- fail ( "Data is left in the database: " + items . toString () );
501
+ fail ( "Data is left in the database: " + items );
504
502
}
505
503
transaction .rollback ();
506
504
}
@@ -519,28 +517,17 @@ protected void assertAllDataRemoved() {
519
517
520
518
protected boolean readCommittedIsolationMaintained (String scenario ) {
521
519
int isolation = Connection .TRANSACTION_READ_UNCOMMITTED ;
522
- Session testSession = null ;
523
- try {
524
- testSession = openSession ();
520
+ try ( Session testSession = openSession () ) {
525
521
isolation = testSession .doReturningWork (
526
- new AbstractReturningWork <Integer >() {
522
+ new AbstractReturningWork <>() {
527
523
@ Override
528
524
public Integer execute (Connection connection ) throws SQLException {
529
525
return connection .getTransactionIsolation ();
530
526
}
531
527
}
532
528
);
533
529
}
534
- catch ( Throwable ignore ) {
535
- }
536
- finally {
537
- if ( testSession != null ) {
538
- try {
539
- testSession .close ();
540
- }
541
- catch ( Throwable ignore ) {
542
- }
543
- }
530
+ catch (Throwable ignore ) {
544
531
}
545
532
if ( isolation < Connection .TRANSACTION_READ_COMMITTED ) {
546
533
SkipLog .reportSkip ( "environment does not support at least read committed isolation" , scenario );
0 commit comments