Commit ffe576b79ec8c0b9530b261ecc304d3d8f7e3968
Merge branch '3.0.0-SNAPSHOT' of https://github.com/demoiselle/framework into 3.0.0-SNAPSHOT
Showing
2 changed files
with
33 additions
and
0 deletions
Show diff stats
demoiselle-persistence-jpa/src/main/java/org/demoiselle/jee/persistence/jpa/bootstrap/PersistenceBootstrap.java
0 → 100644
@@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
1 | +package org.demoiselle.jee.persistence.jpa.bootstrap; | ||
2 | + | ||
3 | +import javax.enterprise.event.Observes; | ||
4 | +import javax.enterprise.inject.spi.AnnotatedType; | ||
5 | +import javax.enterprise.inject.spi.ProcessAnnotatedType; | ||
6 | +import javax.persistence.Entity; | ||
7 | + | ||
8 | +/** | ||
9 | + * | ||
10 | + * Este processo evita que o CDI faça a gestão da entidade no lugar do EntityManager. Garantindo que o EntityManager faça a gestão. | ||
11 | + * | ||
12 | + * http://www.cdi-spec.org/faq/ | ||
13 | + * Why is @Vetoed a best practice for persistent (JPA) entities? | ||
14 | + * | ||
15 | + * @author SERPRO | ||
16 | + * | ||
17 | + */ | ||
18 | +public class PersistenceBootstrap implements javax.enterprise.inject.spi.Extension { | ||
19 | + | ||
20 | + /** | ||
21 | + * Adiciona Vetoed nas entidades | ||
22 | + * @param pat | ||
23 | + */ | ||
24 | + @SuppressWarnings({ "rawtypes", "unchecked" }) | ||
25 | + public void processAnnotatedType(@Observes final ProcessAnnotatedType pat) { | ||
26 | + final AnnotatedType annotatedType = pat.getAnnotatedType(); | ||
27 | + if (annotatedType.getJavaClass().isAnnotationPresent(Entity.class)) { | ||
28 | + pat.veto(); | ||
29 | + } | ||
30 | + } | ||
31 | + | ||
32 | +} |
demoiselle-persistence-jpa/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
0 → 100644