]> git.mxchange.org Git - pizzaservice-ejb.git/commitdiff
Please cherry-pick:
authorRoland Häder <roland@mxchange.org>
Tue, 19 Sep 2017 20:35:27 +0000 (22:35 +0200)
committerRoland Häder <roland@mxchange.org>
Mon, 15 Jul 2019 04:11:56 +0000 (06:11 +0200)
- implemented business method findBranchOfficeById()
- fixed mobileProvider EJB name (which is part of portable name)

Signed-off-by: Roland Häder <roland@mxchange.org>
src/java/org/mxchange/jcontactsbusiness/model/branchoffice/PizzaBranchOfficeSessionBean.java
src/java/org/mxchange/jphone/model/phonenumbers/mobileprovider/PizzaMobileProviderSingletonBean.java

index 8255d81f7ff8af83b7e6f8af20500ccfbd6c58cb..47a3a60364a3d86ac519f30f0f2baf283e9241d8 100644 (file)
@@ -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<roland@mxchange.org>
  */
 @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;
+       }
+
 }
index 194f439127cf8950072ed015aa6f6ebe8f1f3e10..3ae2b4cc09615a91e6f775dc80b88c16f1dc105f 100644 (file)
@@ -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