Commit b43364bf1a2b17bc911cd516ef45748ef904accc
1 parent
e3381276
Exists in
master
Refatoramento do método findAll para uso do findByJPQL.
Correção do parser JPQL para uso da rotina count
Showing
1 changed file
with
2 additions
and
13 deletions
Show diff stats
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java
... | ... | @@ -162,20 +162,8 @@ public class JPACrud<T, I> implements Crud<T, I> { |
162 | 162 | } |
163 | 163 | |
164 | 164 | @Override |
165 | - @SuppressWarnings("unchecked") | |
166 | 165 | public List<T> findAll() { |
167 | - final String jpql = "select this from " + getBeanClass().getSimpleName() + " this"; | |
168 | - final Query query = getEntityManager().createQuery(jpql); | |
169 | - | |
170 | - final Pagination pagination = getPagination(); | |
171 | - if (pagination != null) { | |
172 | - pagination.setTotalResults(this.countAll().intValue()); | |
173 | - query.setFirstResult(pagination.getFirstResult()); | |
174 | - query.setMaxResults(pagination.getPageSize()); | |
175 | - } | |
176 | - | |
177 | - List<T> lista = query.getResultList(); | |
178 | - return lista; | |
166 | + return findByJPQL("select this from " + getBeanClass().getSimpleName() + " this"); | |
179 | 167 | } |
180 | 168 | |
181 | 169 | /** |
... | ... | @@ -224,6 +212,7 @@ public class JPACrud<T, I> implements Crud<T, I> { |
224 | 212 | * @return |
225 | 213 | */ |
226 | 214 | private String createCountQueryString(String query) { |
215 | + query = query.toUpperCase(); | |
227 | 216 | Matcher matcher = Pattern.compile("SELECT(.+)FROM").matcher(query); |
228 | 217 | if (matcher.find()){ |
229 | 218 | String group = matcher.group(1).trim(); | ... | ... |