@Test public void getLineItemsByOrderId_shouldFindListWithExistingLineItemsByOrderId() { LineItem existingLineItem = createLineItemBuilderWithAllFields(existingItem).build(); persistence.create(existingLineItem); List<LineItem> lineItems = persistence.getLineItemsByOrderId(existingLineItem.getOrderId()); assertThat(lineItems.size(), is(1)); assertHaveSamePersistentFields(existingLineItem, lineItems.get(0), "item"); }
@Override public List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId) { Query query = getEntityManager().createQuery("select li from LineItem li where li.orderId = :orderId"); query.setParameter("orderId", orderId); @SuppressWarnings("unchecked") List<LineItem> lineItems = (List<LineItem>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] line item(s) for order id[{}]", lineItems.size(), orderId); return lineItems; }
LineItemBasePersistence extends AbstractBasePersistence<LineItem, String> implements LineItemMapper { @Override public List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId) { Query query = getEntityManager().createQuery("select li from LineItem li where li.orderId = :orderId"); query.setParameter("orderId", orderId); @SuppressWarnings("unchecked") List<LineItem> lineItems = (List<LineItem>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] line item(s) for order id[{}]", lineItems.size(), orderId); return lineItems; } }
LineItemBasePersistence extends AbstractBasePersistence<LineItem, String> implements LineItemMapper { @Override public List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId) { Query query = getEntityManager().createQuery("select li from LineItem li where li.orderId = :orderId"); query.setParameter("orderId", orderId); @SuppressWarnings("unchecked") List<LineItem> lineItems = (List<LineItem>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] line item(s) for order id[{}]", lineItems.size(), orderId); return lineItems; }  }
LineItemBasePersistence extends AbstractBasePersistence<LineItem, String> implements LineItemMapper { @Override public List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId) { Query query = getEntityManager().createQuery("select li from LineItem li where li.orderId = :orderId"); query.setParameter("orderId", orderId); @SuppressWarnings("unchecked") List<LineItem> lineItems = (List<LineItem>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] line item(s) for order id[{}]", lineItems.size(), orderId); return lineItems; }  @Override List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId); @Override void insertLineItem(@Nonnull final LineItem lineItem); }
LineItemBasePersistence extends AbstractBasePersistence<LineItem, String> implements LineItemMapper { @Override public List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId) { Query query = getEntityManager().createQuery("select li from LineItem li where li.orderId = :orderId"); query.setParameter("orderId", orderId); @SuppressWarnings("unchecked") List<LineItem> lineItems = (List<LineItem>) query.getResultList(); closeEntityManager(); logger.info("Read [{}] line item(s) for order id[{}]", lineItems.size(), orderId); return lineItems; }  @Override List<LineItem> getLineItemsByOrderId(@Nonnull final String orderId); @Override void insertLineItem(@Nonnull final LineItem lineItem);  }