From 31452becde93e6fcc7edd280f28643c10ca08bb2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 19 Sep 2017 22:35:27 +0200 Subject: [PATCH] Please cherry-pick: - implemented business method findBranchOfficeById() - fixed mobileProvider EJB name (which is part of portable name) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Roland Häder --- .../PizzaBranchOfficeSessionBean.java | 39 ++++++++++++++++++- .../PizzaMobileProviderSingletonBean.java | 4 +- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java index 8255d81..47a3a60 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java @@ -19,8 +19,10 @@ package org.mxchange.jcontactsbusiness.model.branchoffice; import java.text.MessageFormat; import java.util.List; import javax.ejb.Stateless; +import javax.persistence.NoResultException; import javax.persistence.Query; -import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; +import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean; +import org.mxchange.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; /** * A stateless session bean for general branch office purposes @@ -28,7 +30,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; * @author Roland Häder */ @Stateless (name = "branchOffice", description = "A general statless bean for handling branch office data (all)") -public class PizzaBranchOfficeSessionBean extends BasePizzaDatabaseBean implements BranchOfficeSessionBeanRemote { +public class PizzaBranchOfficeSessionBean extends BasePizzaEnterpriseBean implements BranchOfficeSessionBeanRemote { /** * Serial number @@ -54,4 +56,37 @@ public class PizzaBranchOfficeSessionBean extends BasePizzaDatabaseBean implemen return list; } + @Override + public BranchOffice findBranchOfficeById (final Long branchOfficeId) throws BranchOfficeNotFoundException { + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: CALLED!", this.getClass().getSimpleName())); //NOI18N + + // Get query + final Query query = this.getEntityManager().createNamedQuery("SearchBranchOfficeById", CompanyBranchOffice.class); //NOI18N + + // Set parameter + query.setParameter("branchOfficeId", branchOfficeId); //NOI18N + + // Get single instance + final BranchOffice branchOffice; + + // Try to find a result + try { + // Find a single result + branchOffice = (BranchOffice) query.getSingleResult(); + + // Log trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: Found branchOffice={1}", this.getClass().getSimpleName(), branchOffice)); //NOI18N + } catch (final NoResultException ex) { + // No result found + throw new BranchOfficeNotFoundException(branchOfficeId, ex); + } + + // Trace message + this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBranchOfficeById: branchOffice={1} - EXIT!", this.getClass().getSimpleName(), branchOffice)); //NOI18N + + // Return it + return branchOffice; + } + } diff --git a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java index 194f439..3ae2b4c 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java @@ -21,7 +21,7 @@ import java.util.List; import javax.ejb.Singleton; import javax.ejb.Startup; import javax.persistence.Query; -import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; +import org.mxchange.pizzaaplication.database.BasePizzaEnterpriseBean; /** * A singleton EJB for mobile provider informations @@ -30,7 +30,7 @@ import org.mxchange.pizzaaplication.database.BasePizzaDatabaseBean; */ @Startup @Singleton (name = "mobileProvider", description = "A singleton session-scoped bean for SMS provider informations") -public class PizzaMobileProviderSingletonBean extends BasePizzaDatabaseBean implements MobileProviderSingletonBeanRemote { +public class PizzaMobileProviderSingletonBean extends BasePizzaEnterpriseBean implements MobileProviderSingletonBeanRemote { /** * Serial number -- 2.39.5