From fc022111b8852972329f22e2e01b16ba13479feb 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 --- .../FinancialsBranchOfficeSessionBean.java | 35 +++++++++++++++++++ ...FinancialsMobileProviderSingletonBean.java | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/FinancialsBranchOfficeSessionBean.java b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/FinancialsBranchOfficeSessionBean.java index fe6647b..21971f0 100644 --- a/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/FinancialsBranchOfficeSessionBean.java +++ b/src/java/org/mxchange/jcontactsbusiness/model/branchoffice/FinancialsBranchOfficeSessionBean.java @@ -19,7 +19,9 @@ 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.jcontactsbusiness.exceptions.branchoffice.BranchOfficeNotFoundException; import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; /** @@ -54,4 +56,37 @@ public class FinancialsBranchOfficeSessionBean extends BaseFinancialsDatabaseBea 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/FinancialsMobileProviderSingletonBean.java b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java index ed4387d..4208c68 100644 --- a/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java +++ b/src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/FinancialsMobileProviderSingletonBean.java @@ -29,7 +29,7 @@ import org.mxchange.jfinancials.database.BaseFinancialsDatabaseBean; * @author Roland Häder */ @Startup -@Singleton (name = "mobileprovider", description = "A singleton session-scoped bean for SMS provider informations") +@Singleton (name = "mobileProvider", description = "A singleton session-scoped bean for SMS provider informations") public class FinancialsMobileProviderSingletonBean extends BaseFinancialsDatabaseBean implements MobileProviderSingletonBeanRemote { /** -- 2.39.5