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);
 }
 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());
 }
 public List<CartItemDTO> historyByClient(Integer page, Integer maxRecords, Long idClient) {
   Query q =
       em.createQuery(
           "select u from "
               + entityClass.getSimpleName()
               + " u where u.client.id = :idC and u.order IS NOT NULL");
   if (page != null && maxRecords != null) {
     q.setFirstResult((page - 1) * maxRecords);
     q.setMaxResults(maxRecords);
   }
   return CartItemConverter.listEntity2DTO(q.setParameter("idC", idClient).getResultList());
 }