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
* @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
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;
+ }
+
}
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
*/
@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