2 * Copyright (C) 2017 Roland Häder
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Affero General Public License as
6 * published by the Free Software Foundation, either version 3 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Affero General Public License for more details.
14 * You should have received a copy of the GNU Affero General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package org.mxchange.jcontactsbusiness.basicdata;
19 import java.text.MessageFormat;
20 import javax.ejb.Stateless;
21 import javax.persistence.NoResultException;
22 import javax.persistence.Query;
23 import org.mxchange.jcontactsbusiness.exceptions.basicdata.BusinessDataNotFoundException;
24 import org.mxchange.jjobs.database.BaseJobsDatabaseBean;
27 * A stateless session bean for business data
29 * @author Roland Häder<roland@mxchange.org>
31 @Stateless (name = "businessData", description = "A general statless bean for handling business data (all)")
32 public class JobsBusinessDataSessionBean extends BaseJobsDatabaseBean implements BusinessDataSessionBeanRemote {
37 private static final long serialVersionUID = 56_389_504_892_184_571L;
42 public JobsBusinessDataSessionBean () {
43 // Call super constructor
48 public BusinessBasicData findBusinessDataById (final Long businessDataId) throws BusinessDataNotFoundException {
50 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBusinessDataById: CALLED!", this.getClass().getSimpleName())); //NOI18N
53 Query query = this.getEntityManager().createNamedQuery("SearchBusinessDataById", CompanyBasicData.class); //NOI18N
56 query.setParameter("businessDataId", businessDataId); //NOI18N
58 // Get single instance
59 BusinessBasicData businessData = null;
61 // Try to find a result
63 // Find a single result
64 businessData = (BusinessBasicData) query.getSingleResult();
67 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBusinessDataById: Found contact={1}", this.getClass().getSimpleName(), businessData)); //NOI18N
68 } catch (final NoResultException ex) {
70 throw new BusinessDataNotFoundException(businessDataId, ex);
74 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.findBusinessDataById: businessData={1} - EXIT!", this.getClass().getSimpleName(), businessData)); //NOI18N