Commit b43364bf1a2b17bc911cd516ef45748ef904accc

Authored by Vanderson Silva
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
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,20 +162,8 @@ public class JPACrud<T, I> implements Crud<T, I> {
162 } 162 }
163 163
164 @Override 164 @Override
165 - @SuppressWarnings("unchecked")  
166 public List<T> findAll() { 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&lt;T, I&gt; implements Crud&lt;T, I&gt; { @@ -224,6 +212,7 @@ public class JPACrud&lt;T, I&gt; implements Crud&lt;T, I&gt; {
224 * @return 212 * @return
225 */ 213 */
226 private String createCountQueryString(String query) { 214 private String createCountQueryString(String query) {
  215 + query = query.toUpperCase();
227 Matcher matcher = Pattern.compile("SELECT(.+)FROM").matcher(query); 216 Matcher matcher = Pattern.compile("SELECT(.+)FROM").matcher(query);
228 if (matcher.find()){ 217 if (matcher.find()){
229 String group = matcher.group(1).trim(); 218 String group = matcher.group(1).trim();