]> git.mxchange.org Git - pizzaservice-ejb.git/blob - src/java/org/mxchange/jcontactsbusiness/model/employee/PizzaEmployeeSessionBean.java
914132917107d01d410480bedd2efdd3458171d7
[pizzaservice-ejb.git] / src / java / org / mxchange / jcontactsbusiness / model / employee / PizzaEmployeeSessionBean.java
1 /*
2  * Copyright (C) 2017 - 2020 Free Software Foundation
3  *
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.
8  *
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.
13  *
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/>.
16  */
17 package org.mxchange.jcontactsbusiness.model.employee;
18
19 import java.text.MessageFormat;
20 import java.util.List;
21 import javax.ejb.Stateless;
22 import javax.persistence.Query;
23 import org.mxchange.pizzaaplication.enterprise.BasePizzaEnterpriseBean;
24
25 /**
26  * A stateless bean for general purposes for company employees.
27  * <p>
28  * @author Roland Häder<roland@mxchange.org>
29  */
30 @Stateless (name = "employee", description = "A general statless bean for handling company employees")
31 public class PizzaEmployeeSessionBean extends BasePizzaEnterpriseBean implements EmployeeSessionBeanRemote {
32
33         /**
34          * Serial number
35          */
36         private static final long serialVersionUID = 26_458_796_703_762L;
37
38         /**
39          * Default constructor
40          */
41         public PizzaEmployeeSessionBean () {
42                 super();
43         }
44
45         @Override
46         @SuppressWarnings ("unchecked")
47         public List<Employable> fetchAllEmployees () {
48                 // Trace message
49                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allEmployees(): CALLED!", this.getClass().getSimpleName())); //NOI18N
50
51                 // Get named query
52                 final Query query = this.getEntityManager().createNamedQuery("AllEmployees"); //NOI18N
53
54                 // Get list form it
55                 final List<Employable> employees = query.getResultList();
56
57                 // Trace message
58                 this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allEmployees(): employees.size()={1} - EXIT!", this.getClass().getSimpleName(), employees.size())); //NOI18N
59
60                 // Return it
61                 return employees;
62         }
63
64 }