aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java')
-rw-r--r--utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java37
1 files changed, 15 insertions, 22 deletions
diff --git a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java
index 3552a6fa..131e87a4 100644
--- a/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java
+++ b/utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java
@@ -2,14 +2,15 @@
* ============LICENSE_START=======================================================
* Common Utils
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018, 2021 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +21,8 @@
package org.onap.policy.common.utils.jpa;
-import javax.persistence.EntityTransaction;
+import jakarta.persistence.EntityTransaction;
+import lombok.Getter;
/**
* Wrapper for an <i>EntityTransaction</i> that is auto-rolled back when closed. This is useful in
@@ -31,46 +33,37 @@ public class EntityTransCloser implements AutoCloseable {
/**
* Transaction to be rolled back.
*/
- private final EntityTransaction trans;
+ @Getter
+ private final EntityTransaction transaction;
/**
* Begins a transaction.
- *
+ *
* @param et transaction to wrap/begin
*/
public EntityTransCloser(EntityTransaction et) {
- trans = et;
- trans.begin();
- }
-
- /**
- * Gets the wrapped transaction.
- *
- * @return the transaction
- */
- public EntityTransaction getTransation() {
- return trans;
+ transaction = et;
+ transaction.begin();
}
/**
* Commits the transaction.
*/
public void commit() {
- trans.commit();
+ transaction.commit();
}
/**
* Rolls back the transaction.
*/
public void rollback() {
- trans.rollback();
+ transaction.rollback();
}
@Override
public void close() {
- if (trans.isActive()) {
- trans.rollback();
+ if (transaction.isActive()) {
+ transaction.rollback();
}
}
-
}