@Test public void getOrderByUsername_shouldFindListWithExistingOrders() { Order existingOrder = createOrderWithAllFields(); existingOrder.setIntOrderId(1); persistence.create(existingOrder); List<Order> orders = persistence.getOrdersByUsername(existingOrder.getUsername()); assertThat(orders.size(), is(1)); assertHaveSamePersistentFields(existingOrder, orders.get(0), "lineItems"); }
@Override public List<Order> getOrdersByUsername(@Nonnull final String username) { Query query = getEntityManager().createQuery("select o from Order o where o.username = :username"); query.setParameter("username", username); @SuppressWarnings("unchecked") List<Order> orders = query.getResultList(); closeEntityManager(); logger.info("Read [{}] order(s) for username[{}]", orders.size(), username); return orders; }
OrderBasePersistence extends AbstractBasePersistence<Order, String> implements OrderMapper { @Override public List<Order> getOrdersByUsername(@Nonnull final String username) { Query query = getEntityManager().createQuery("select o from Order o where o.username = :username"); query.setParameter("username", username); @SuppressWarnings("unchecked") List<Order> orders = query.getResultList(); closeEntityManager(); logger.info("Read [{}] order(s) for username[{}]", orders.size(), username); return orders; } }
OrderBasePersistence extends AbstractBasePersistence<Order, String> implements OrderMapper { @Override public List<Order> getOrdersByUsername(@Nonnull final String username) { Query query = getEntityManager().createQuery("select o from Order o where o.username = :username"); query.setParameter("username", username); @SuppressWarnings("unchecked") List<Order> orders = query.getResultList(); closeEntityManager(); logger.info("Read [{}] order(s) for username[{}]", orders.size(), username); return orders; }  }
OrderBasePersistence extends AbstractBasePersistence<Order, String> implements OrderMapper { @Override public List<Order> getOrdersByUsername(@Nonnull final String username) { Query query = getEntityManager().createQuery("select o from Order o where o.username = :username"); query.setParameter("username", username); @SuppressWarnings("unchecked") List<Order> orders = query.getResultList(); closeEntityManager(); logger.info("Read [{}] order(s) for username[{}]", orders.size(), username); return orders; }  @Override List<Order> getOrdersByUsername(@Nonnull final String username); @Override Order getOrder(@Nonnull final String orderId); @Override void insertOrder(@Nonnull final Order order); @Override void insertOrderStatus(@Nonnull final Order order); }
OrderBasePersistence extends AbstractBasePersistence<Order, String> implements OrderMapper { @Override public List<Order> getOrdersByUsername(@Nonnull final String username) { Query query = getEntityManager().createQuery("select o from Order o where o.username = :username"); query.setParameter("username", username); @SuppressWarnings("unchecked") List<Order> orders = query.getResultList(); closeEntityManager(); logger.info("Read [{}] order(s) for username[{}]", orders.size(), username); return orders; }  @Override List<Order> getOrdersByUsername(@Nonnull final String username); @Override Order getOrder(@Nonnull final String orderId); @Override void insertOrder(@Nonnull final Order order); @Override void insertOrderStatus(@Nonnull final Order order);  }