Commit 9ae5e3de8c5dd8fb17c919cec9cf02389dc7f77e
1 parent
7fb2f741
Exists in
master
Correção de bug na extração do nome da entidade
Showing
1 changed file
with
12 additions
and
1 deletions
Show diff stats
impl/extension/jpa/src/main/java/br/gov/frameworkdemoiselle/template/JPACrud.java
| ... | ... | @@ -47,6 +47,7 @@ import javax.enterprise.inject.Instance; |
| 47 | 47 | import javax.inject.Inject; |
| 48 | 48 | import javax.persistence.Basic; |
| 49 | 49 | import javax.persistence.Column; |
| 50 | +import javax.persistence.Entity; | |
| 50 | 51 | import javax.persistence.EntityExistsException; |
| 51 | 52 | import javax.persistence.EntityManager; |
| 52 | 53 | import javax.persistence.Enumerated; |
| ... | ... | @@ -195,7 +196,17 @@ public class JPACrud<T, I> implements Crud<T, I> { |
| 195 | 196 | |
| 196 | 197 | @Override |
| 197 | 198 | public List<T> findAll() { |
| 198 | - return findByJPQL("select this from " + getBeanClass().getSimpleName() + " this"); | |
| 199 | + Entity entityAnnotation = getBeanClass().getAnnotation(Entity.class); | |
| 200 | + String entityName = null; | |
| 201 | + if (entityAnnotation!=null | |
| 202 | + && entityAnnotation.name()!=null | |
| 203 | + && !entityAnnotation.name().trim().equals("")) { | |
| 204 | + entityName = entityAnnotation.name(); | |
| 205 | + } | |
| 206 | + else { | |
| 207 | + entityName = getBeanClass().getSimpleName(); | |
| 208 | + } | |
| 209 | + return findByJPQL("select this from " + entityName + " this"); | |
| 199 | 210 | } |
| 200 | 211 | |
| 201 | 212 | /** | ... | ... |