import java.text.MessageFormat;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
import javax.ejb.Stateless;
throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
}
- // Query all
- final Query query = this.getEntityManager().createNamedQuery("SearchAllUserReceipts"); //NOI18N
-
- // Add parameter
- query.setParameter("receiptUser", user); //NOI18N
+ // Init list
+ final List<BillableReceipt> receipts = new LinkedList<>();
- // Get all
- final List<BillableReceipt> receipts = query.getResultList();
+ // Iterate over all records
+ for (final BillableReceipt currentReceipt : this.fetchAllReceipts()) {
+ // Does the user match?
+ if (Objects.equals(user, currentReceipt.getReceiptUser())) {
+ // Yes, then add to list
+ receipts.add(currentReceipt);
+ }
+ }
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsersReceipts(): receipts.size()={1} EXIT!", this.getClass().getSimpleName(), receipts.size())); //NOI18N
import java.text.MessageFormat;
import java.util.Date;
+import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import javax.ejb.Stateless;
import javax.persistence.Query;
import org.mxchange.jfinancials.enterprise.BaseFinancialsEnterpriseBean;
}
@Override
- @SuppressWarnings ("unchecked")
public List<BillableReceiptItem> fetchReceiptItemsByReceipt (final BillableReceipt receipt) {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceiptItems(): receipt={1} - CALLED!", this.getClass().getSimpleName(), receipt)); //NOI18N
- // Get named query
- final Query query = this.getEntityManager().createNamedQuery("SearchAssignedReceiptItems"); //NOI18N
-
- // Set parameter
- query.setParameter("itemReceipt", receipt); //NOI18N
+ // Init list
+ final List<BillableReceiptItem> receiptItems = new LinkedList<>();
- // Get list
- final List<BillableReceiptItem> receiptItems = query.getResultList();
+ // Iterate over all records
+ for (final BillableReceiptItem currentReceiptItem : this.fetchAllReceiptItems()) {
+ // Does the receipt match?
+ if (Objects.equals(receipt, currentReceiptItem.getItemReceipt())) {
+ // Yes, then add to list
+ receiptItems.add(currentReceiptItem);
+ }
+ }
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceiptItems(): receiptItems()={1} EXIT!", this.getClass().getSimpleName(), receiptItems.size())); //NOI18N
}
@Override
- @SuppressWarnings ("unchecked")
public List<BillableReceiptItem> fetchReceiptItemsByUserUser (final User user) {
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allUsersReceiptItems(): user={1} - CALLED!", this.getClass().getSimpleName(), user)); //NOI18N
- // Get named query
- final Query query = this.getEntityManager().createNamedQuery("SearchAllUserReceiptItems"); //NOI18N
-
- // Set parameter
- query.setParameter("receiptUser", user); //NOI18N
+ // Init list
+ final List<BillableReceiptItem> receiptItems = new LinkedList<>();
- // Get list
- final List<BillableReceiptItem> receiptItems = query.getResultList();
+ // Iterate over all records
+ for (final BillableReceiptItem currentReceiptItem : this.fetchAllReceiptItems()) {
+ // Does the user match?
+ if (Objects.equals(user, currentReceiptItem.getItemReceipt().getReceiptUser())) {
+ // Yes, then add to list
+ receiptItems.add(currentReceiptItem);
+ }
+ }
// Trace message
this.getLoggerBeanLocal().logTrace(MessageFormat.format("{0}.allReceiptItems(): receiptItems()={1} EXIT!", this.getClass().getSimpleName(), receiptItems.size())); //NOI18N