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()); }