Rev 264 | Rev 514 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 264 | Rev 467 | ||
|---|---|---|---|
| Line 6... | Line 6... | ||
| 6 | 6 | ||
| 7 | import org.springframework.stereotype.Repository; |
7 | import org.springframework.stereotype.Repository; |
| 8 | 8 | ||
| 9 | import br.com.ec.core.util.VerificadorUtil; |
9 | import br.com.ec.core.util.VerificadorUtil; |
| 10 | import br.com.ec.domain.dto.LojaDTO; |
10 | import br.com.ec.domain.dto.LojaDTO; |
| - | 11 | import br.com.ec.domain.dto.PessoaDTO; |
|
| 11 | import br.com.ec.domain.model.Loja; |
12 | import br.com.ec.domain.model.Loja; |
| - | 13 | import br.com.ec.domain.model.Pessoa; |
|
| 12 | import br.com.ec.repository.LojaRepository; |
14 | import br.com.ec.repository.LojaRepository; |
| 13 | import br.com.ec.repository.SistemaAbstractRepository; |
15 | import br.com.ec.repository.SistemaAbstractRepository; |
| 14 | 16 | ||
| 15 | @Repository |
17 | @Repository |
| 16 | public class LojaRepositoryJpaImpl extends SistemaAbstractRepository<Loja> implements LojaRepository { |
18 | public class LojaRepositoryJpaImpl extends SistemaAbstractRepository<Loja> implements LojaRepository { |
| Line 33... | Line 35... | ||
| 33 | TypedQuery<LojaDTO> query = getEntityManager().createQuery(jpql.toString(), LojaDTO.class); |
35 | TypedQuery<LojaDTO> query = getEntityManager().createQuery(jpql.toString(), LojaDTO.class); |
| 34 | if (VerificadorUtil.naoEstaNulo(ativo)) { |
36 | if (VerificadorUtil.naoEstaNulo(ativo)) { |
| 35 | query.setParameter("indicadorAtivo", ativo); |
37 | query.setParameter("indicadorAtivo", ativo); |
| 36 | }
|
38 | }
|
| 37 | return query.getResultList(); |
39 | return query.getResultList(); |
| - | 40 | } catch (Exception ex) { |
|
| - | 41 | ex.printStackTrace(); |
|
| - | 42 | }
|
|
| - | 43 | return null; |
|
| - | 44 | }
|
|
| - | 45 | ||
| - | 46 | @Override |
|
| - | 47 | public LojaDTO consultarLojaPelaPessoa(Long sequencialPessoa) { |
|
| - | 48 | StringBuilder jpql = new StringBuilder(); |
|
| - | 49 | jpql.append("SELECT new br.com.ec.domain.dto.LojaDTO("); |
|
| - | 50 | jpql.append(PessoaDTO.CONSULTA_DTO_COMPLETA); |
|
| - | 51 | jpql.append(") FROM Loja e "); |
|
| - | 52 | jpql.append("WHERE e.pessoaJuridica.sequencial = :sequencialPessoa"); |
|
| - | 53 | try { |
|
| - | 54 | return getEntityManager().createQuery(jpql.toString(), LojaDTO.class).setParameter("sequencialPessoa", sequencialPessoa).getSingleResult(); |
|
| 38 | } catch (Exception ex) { |
55 | } catch (Exception ex) { |
| 39 | ex.printStackTrace(); |
56 | ex.printStackTrace(); |
| 40 | }
|
57 | }
|
| 41 | return null; |
58 | return null; |
| 42 | }
|
59 | }
|