From: Roland Haeder Date: Fri, 9 Oct 2015 12:48:45 +0000 (+0200) Subject: Added business method getUsersList() and implemented it. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=376898aa5bd021eeacad71c631a82224d8bc2949;p=jfinancials-ejb.git Added business method getUsersList() and implemented it. Signed-off-by:Roland Häder --- diff --git a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java index 245c3a7..6bd71d8 100644 --- a/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java +++ b/src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java @@ -16,10 +16,13 @@ */ package org.mxchange.addressbook.model.addressbook; +import java.util.List; import javax.ejb.EJB; import javax.ejb.Stateless; +import javax.persistence.Query; import org.mxchange.jcoreee.database.BaseDatabaseBean; import org.mxchange.jusercore.model.login.UserLoginSessionBeanRemote; +import org.mxchange.jusercore.model.user.User; /** * A stateless bean handling addressbooks @@ -39,4 +42,20 @@ public class AddressbookSessionBean extends BaseDatabaseBean implements Addressb */ @EJB private UserLoginSessionBeanRemote loginBean; + + @Override + @SuppressWarnings ("unchecked") + public List getUsersList (final User loggedInUser) { + // Get query instance + Query query = this.getEntityManager().createNamedQuery("AllUsersAddressbooks"); //NOI18N + + // Set parameter + query.setParameter("param", loggedInUser); //NOI18N + + // Get full list from JPA + List addressbooks = query.getResultList(); + + // Return it + return addressbooks; + } }