--- /dev/null
+/*
+ * Copyright (C) 2016 Roland Haeder
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jphone.phonenumbers.phone;
+
+import java.text.MessageFormat;
+import javax.ejb.Stateless;
+import javax.persistence.NoResultException;
+import javax.persistence.Query;
+import org.mxchange.jcoreee.database.BaseDatabaseBean;
+import org.mxchange.jphone.exceptions.PhoneEntityNotFoundException;
+import org.mxchange.jphone.phonenumbers.cellphone.CellphoneNumber;
+import org.mxchange.jphone.phonenumbers.cellphone.DialableCellphoneNumber;
+
+/**
+ * A general phone EJB
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Stateless (name = "phone", mappedName = "ejb/stateless-pizza-phone", description = "A bean handling phone data")
+public class PizzaPhoneSessionBean extends BaseDatabaseBean implements PhoneSessionBeanRemote {
+
+ /**
+ * Serial number
+ */
+ private static final long serialVersionUID = 134_945_698_127_601L;
+
+ /**
+ * Default constructor
+ */
+ public PizzaPhoneSessionBean () {
+ }
+
+ @Override
+ public DialableCellphoneNumber findCellphoneById (final Long cellphoneId) throws PhoneEntityNotFoundException {
+ // The id number should be valid
+ if (null == cellphoneId) {
+ // Throw NPE
+ throw new NullPointerException("cellphoneId is null"); //NOI18N
+ } else if (cellphoneId < 1) {
+ // Not valid
+ throw new IllegalArgumentException(MessageFormat.format("cellphoneId={0} is not valid.", cellphoneId)); //NOI18N
+ }
+
+ // Now find it
+ Query query = this.getEntityManager().createNamedQuery("SearchCellphoneId", CellphoneNumber.class); //NOI18N
+
+ // Set parameter
+ query.setParameter("cellphoneId", cellphoneId); //NOI18N
+
+ // Init instance
+ DialableCellphoneNumber cellphone = null;
+
+ // Try to get a result
+ try {
+ // Get a single result
+ cellphone = (DialableCellphoneNumber) query.getSingleResult();
+ } catch (NoResultException ex) {
+ // The entry was not found, so throw it again
+ throw new PhoneEntityNotFoundException(cellphoneId, ex);
+ }
+
+ // Return found instance
+ return cellphone;
+ }
+
+}