From: Roland Häder Date: Tue, 19 Sep 2017 20:35:27 +0000 (+0200) Subject: Please cherry-pick: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=31452becde93e6fcc7edd280f28643c10ca08bb2;p=pizzaservice-ejb.git Please cherry-pick: - implemented business method findBranchOfficeById() - fixed mobileProvider EJB name (which is part of portable name) Signed-off-by: Roland Häder --- 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