]> git.mxchange.org Git - addressbook-ejb.git/commitdiff
Added business method getUsersList() and implemented it.
authorRoland Haeder <roland@mxchange.org>
Fri, 9 Oct 2015 12:48:45 +0000 (14:48 +0200)
committerRoland Haeder <roland@mxchange.org>
Fri, 9 Oct 2015 12:48:45 +0000 (14:48 +0200)
Signed-off-by:Roland Häder <roland@mxchange.org>

src/java/org/mxchange/addressbook/model/addressbook/AddressbookSessionBean.java

index 245c3a7aeab6e194138f9e1cb43e5dc74aae0479..6bd71d8598275f2f9dc685827149a110fcd78329 100644 (file)
  */
 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<Addressbook> 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<Addressbook> addressbooks = query.getResultList();
+
+               // Return it
+               return addressbooks;
+       }
 }