diff options
author | Jim Hahn <jrh3@att.com> | 2021-06-17 13:02:08 -0400 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2021-06-17 13:32:09 -0400 |
commit | d23a8d83d67ab59dee405b29ddbc6dce6fd3c71b (patch) | |
tree | 06b350ac3004e5329e814e9f20a52e1bd088fc18 /utils/src/main/java/org/onap/policy/common/utils/jpa/EntityTransCloser.java | |
parent | 435c3bd346a5f8050cc22df9df223479e5f32573 (diff) |
Use lombok in policy-common utils
Issue-ID: POLICY-3394
Change-Id: I42a18c115c3ca7110f37fc0ae8aeea3f2bbffb37
Signed-off-by: Jim Hahn <jrh3@att.com>
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.java | 34 |
1 files changed, 13 insertions, 21 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..bc5623b0 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,14 @@ * ============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. * ================================================================================ * 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. @@ -21,6 +21,7 @@ package org.onap.policy.common.utils.jpa; import javax.persistence.EntityTransaction; +import lombok.Getter; /** * Wrapper for an <i>EntityTransaction</i> that is auto-rolled back when closed. This is useful in @@ -31,46 +32,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(); } } - } |