@@ -0,0 +1,2234 @@
+/*%0D%0A * To change this license header, choose License Headers in Project Properties.%0D%0A * To change this template file, choose Tools %7C Templates%0D%0A * and open the template in the editor.%0D%0A */%0D%0Apackage br.senac.pi4.ProjetoIntegrador.repository;%0D%0A%0D%0Aimport br.senac.pi4.ProjetoIntegrador.Service.PedidoService;%0D%0Aimport br.senac.pi4.ProjetoIntegrador.entity.Pedido;%0D%0Aimport br.senac.pi4.ProjetoIntegrador.entity.Produto;%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.Date;%0D%0Aimport java.util.Iterator;%0D%0Aimport java.util.List;%0D%0Aimport javax.persistence.EntityManager;%0D%0Aimport javax.persistence.PersistenceContext;%0D%0Aimport javax.persistence.Query;%0D%0Aimport javax.transaction.Transactional;%0D%0Aimport org.springframework.beans.factory.annotation.Autowired;%0D%0Aimport org.springframework.stereotype.Repository;%0D%0A%0D%0A/**%0D%0A *%0D%0A * @author thales.dsouza%0D%0A */%0D%0A@Repository%0D%0Apublic class PedidoServiceImpl implements PedidoService%7B%0D%0A    %0D%0A    @PersistenceContext%0D%0A    private EntityManager entityManager;%0D%0A    %0D%0A    @Autowired%0D%0A    private PedidoRepository repo;%0D%0A    %0D%0A    @Override%0D%0A    public List%3CPedido%3E listar(int offset, int quantidade) %7B%0D%0A        Iterable%3CPedido%3E pedidos = repo.findAll();%0D%0A        Iterator it = pedidos.iterator();%0D%0A        List%3CPedido%3E lista = new ArrayList%3CPedido%3E();%0D%0A        while (it.hasNext()) %7B%0D%0A            Pedido p = (Pedido) it.next();%0D%0A            lista.add(p);%0D%0A        %7D%0D%0A        return lista;%0D%0A    %7D%0D%0A    %0D%0A    @Override%0D%0A    public Pedido obter(Long codigoPedido) %7B%0D%0A        return repo.findOne(codigoPedido);%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    @Transactional%0D%0A    public void incluir(Pedido pedido) %7B%0D%0A        entityManager.persist(pedido);%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    @Transactional%0D%0A    public void alterar(Pedido pedido) %7B%0D%0A        entityManager.merge(pedido);%0D%0A    %7D%0D%0A%0D%0A    @Override%0D%0A    public List%3CPedido%3E pesquisarDatas(Date dataDe, Date dataAte) %7B%0D%0A        Query query = entityManager.createQuery%0D%0A        (%22SELECT p FROM Pedido p WHERE p.dataPedido BETWEEN :startDate AND :endDate%22).setParameter(%22startDate%22, dataDe).setParameter(%22endDate%22, dataAte);%0D%0A        List%3CPedido%3E pedidos = query.getResultList();%0D%0A        if (pedidos == null) %7B%0D%0A            return null;%0D%0A        %7D%0D%0A        return pedidos;%0D%0A    %7D%0D%0A%7D%0D%0A

resolve logo