Rev 259 | Rev 467 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 259 | Rev 264 | ||
|---|---|---|---|
| Line 2... | Line 2... | ||
| 2 | 2 | ||
| 3 | import java.util.List; |
3 | import java.util.List; |
| - | 4 | ||
| - | 5 | import javax.persistence.TypedQuery; |
|
| 4 | 6 | ||
| 5 | import org.springframework.stereotype.Repository; |
7 | import org.springframework.stereotype.Repository; |
| 6 | 8 | ||
| - | 9 | import br.com.ec.core.util.VerificadorUtil; |
|
| 7 | import br.com.ec.domain.dto.LojaDTO; |
10 | import br.com.ec.domain.dto.LojaDTO; |
| 8 | import br.com.ec.domain.model.Loja; |
11 | import br.com.ec.domain.model.Loja; |
| 9 | import br.com.ec.repository.LojaRepository; |
12 | import br.com.ec.repository.LojaRepository; |
| 10 | import br.com.ec.repository.SistemaAbstractRepository; |
13 | import br.com.ec.repository.SistemaAbstractRepository; |
| 11 | 14 | ||
| Line 16... | Line 19... | ||
| 16 | protected String getColunaOrdenadora() { |
19 | protected String getColunaOrdenadora() { |
| 17 | return "ordenador, descricao"; |
20 | return "ordenador, descricao"; |
| 18 | }
|
21 | }
|
| 19 | 22 | ||
| 20 | @Override |
23 | @Override |
| 21 | public List<LojaDTO> consultarLojasAtivas() { |
- | |
| - | 24 | public List<LojaDTO> consultarLojas(Boolean ativo) { |
|
| 22 | StringBuilder jpql = new StringBuilder(); |
25 | StringBuilder jpql = new StringBuilder(); |
| 23 | jpql.append("SELECT new br.com.ec.domain.dto.LojaDTO(l.sequencial, l.descricao) FROM Loja l "); |
26 | jpql.append("SELECT new br.com.ec.domain.dto.LojaDTO(l.sequencial, l.descricao) FROM Loja l "); |
| 24 | jpql.append("WHERE l.ativo = TRUE "); |
- | |
| - | 27 | jpql.append("WHERE 1=1 "); |
|
| - | 28 | if (VerificadorUtil.naoEstaNulo(ativo)) { |
|
| - | 29 | jpql.append("AND l.ativo = :indicadorAtivo "); |
|
| - | 30 | }
|
|
| 25 | jpql.append("ORDER BY l.ordenador "); |
31 | jpql.append("ORDER BY l.ordenador "); |
| 26 | try { |
32 | try { |
| 27 | return getEntityManager().createQuery(jpql.toString(), LojaDTO.class).getResultList(); |
- | |
| - | 33 | TypedQuery<LojaDTO> query = getEntityManager().createQuery(jpql.toString(), LojaDTO.class); |
|
| - | 34 | if (VerificadorUtil.naoEstaNulo(ativo)) { |
|
| - | 35 | query.setParameter("indicadorAtivo", ativo); |
|
| - | 36 | }
|
|
| - | 37 | return query.getResultList(); |
|
| 28 | } catch (Exception ex) { |
38 | } catch (Exception ex) { |
| 29 | ex.printStackTrace(); |
39 | ex.printStackTrace(); |
| 30 | }
|
40 | }
|
| 31 | return null; |
41 | return null; |
| 32 | }
|
42 | }
|