From 59603dffb31aa52b6002fdb6ca7ccefd06c7e386 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Sat, 13 Apr 2024 16:52:26 +0200 Subject: [PATCH] clean up weird code formatting in test Signed-off-by: Gavin King --- .../hibernate/orm/test/batch/BatchTests.java | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTests.java index 525d7fadc7..ec19963fec 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/batch/BatchTests.java @@ -178,10 +178,14 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { } txn.commit(); - } catch (RuntimeException e) { - if (txn != null && txn.isActive()) txn.rollback(); - throw e; - } finally { + } + catch (RuntimeException e) { + if (txn != null && txn.isActive()) { + txn.rollback(); + } + throw e; + } + finally { if (entityManager != null) { entityManager.close(); } @@ -214,10 +218,14 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { } txn.commit(); - } catch (RuntimeException e) { - if (txn != null && txn.isActive()) txn.rollback(); - throw e; - } finally { + } + catch (RuntimeException e) { + if (txn != null && txn.isActive()) { + txn.rollback(); + } + throw e; + } + finally { if (entityManager != null) { entityManager.close(); } @@ -242,10 +250,10 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { Session session = entityManager.unwrap(Session.class); - scrollableResults = session - .createSelectionQuery("select p from Person p") - .setCacheMode(CacheMode.IGNORE) - .scroll(ScrollMode.FORWARD_ONLY); + scrollableResults = + session.createSelectionQuery("select p from Person p") + .setCacheMode(CacheMode.IGNORE) + .scroll(ScrollMode.FORWARD_ONLY); int count = 0; while (scrollableResults.next()) { @@ -259,10 +267,14 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { } txn.commit(); - } catch (RuntimeException e) { - if (txn != null && txn.isActive()) txn.rollback(); - throw e; - } finally { + } + catch (RuntimeException e) { + if (txn != null && txn.isActive()) { + txn.rollback(); + } + throw e; + } + finally { if (scrollableResults != null) { scrollableResults.close(); } @@ -279,7 +291,7 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { //tag::batch-stateless-session-example[] StatelessSession statelessSession = null; Transaction txn = null; - ScrollableResults scrollableResults = null; + ScrollableResults scrollableResults = null; try { SessionFactory sessionFactory = entityManagerFactory().unwrap(SessionFactory.class); statelessSession = sessionFactory.openStatelessSession(); @@ -287,9 +299,9 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { txn = statelessSession.getTransaction(); txn.begin(); - scrollableResults = statelessSession - .createSelectionQuery("select p from Person p") - .scroll(ScrollMode.FORWARD_ONLY); + scrollableResults = + statelessSession.createSelectionQuery("select p from Person p") + .scroll(ScrollMode.FORWARD_ONLY); while (scrollableResults.next()) { Person Person = (Person) scrollableResults.get(); @@ -298,10 +310,14 @@ public class BatchTests extends BaseEntityManagerFunctionalTestCase { } txn.commit(); - } catch (RuntimeException e) { - if (txn != null && txn.getStatus() == TransactionStatus.ACTIVE) txn.rollback(); - throw e; - } finally { + } + catch (RuntimeException e) { + if (txn != null && txn.getStatus() == TransactionStatus.ACTIVE) { + txn.rollback(); + } + throw e; + } + finally { if (scrollableResults != null) { scrollableResults.close(); }