@Override public Amount getAmountOfGoods(Goods goods) { EntityManager em = emf.createEntityManager(); try { return em.find(Goods.class, goods.getId()).getWareHouseImpl().getAmount(); } finally { em.close(); } }
@Override public void exportGoods(Goods goods, Amount amount) { EntityManager em = emf.createEntityManager(); try { em.find(Goods.class, goods.getId()).getWareHouseImpl().decrease(amount); } finally { em.close(); } }
@Override public boolean canExport(Goods goods, Amount amount) { EntityManager em = emf.createEntityManager(); try { return em.find(Goods.class, goods.getId()).getWareHouseImpl().getAmount().compareTo(amount) >= 0 ? true : false; } finally { em.close(); } }