Пример #1
0
 public CartItemDTO createCartItemByClient(CartItemDTO dto, Long idClient) {
   CartItemEntity entity = CartItemConverter.fullDTO2Entity(dto);
   ClientEntity clientEntity = em.find(ClientEntity.class, idClient);
   entity.setClient(clientEntity);
   em.persist(entity);
   return CartItemConverter.fullEntity2DTO(entity);
 }
Пример #2
0
 public CartItemDTO getCartItemsByClientById(Long idCart, Long idClient) {
   Query q =
       em.createQuery(
           "select u from "
               + entityClass.getSimpleName()
               + " u where u.client.id = :idC and u.id= :id");
   return CartItemConverter.fullEntity2DTO(
       (CartItemEntity)
           q.setParameter("idC", idClient).setParameter("id", idCart).getSingleResult());
 }
Пример #3
0
 public List<CartItemDTO> getCartItemsByClient(Integer page, Integer maxRecords, Long idClient) {
   Query q =
       em.createQuery(
           "select u from " + entityClass.getSimpleName() + " u where u.client.id = :idC");
   if (page != null && maxRecords != null) {
     q.setFirstResult((page - 1) * maxRecords);
     q.setMaxResults(maxRecords);
   }
   return CartItemConverter.listEntity2DTO(q.setParameter("idC", idClient).getResultList());
 }