DATAJPA-1175 - Remove EntityManager injection in QuerydslRepositorySupport.
We no longer declare entity manager injection in QuerydslRepositorySupport to prevent annotation-triggered class path scanning from touching this class. Class path scans can fail because Querydsl is an optional dependency and @PersistenceContext is a marker for environments like CDI to initiate a class path scan. Depending on the scan implementation, reflection-based scanners are known to fail because the class cannot be linked without Querydsl on the class path. We decided to remove injection entirely to move the injection responsibility to code building upon QuerydslRepositorySupport. Using Autowired would work only in Spring environments and not pure Java EE environments (EJB, CDI). Using @Inject would cause the same effect as @PersistenceContext.
This commit is contained in:
committed by
Oliver Gierke
parent
606deaa1c8
commit
bb0aa945c8
@@ -17,7 +17,6 @@ package org.springframework.data.jpa.repository.support;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -32,8 +31,8 @@ import com.querydsl.jpa.impl.JPADeleteClause;
|
||||
import com.querydsl.jpa.impl.JPAUpdateClause;
|
||||
|
||||
/**
|
||||
* Base class for implementing repositories using QueryDsl library.
|
||||
*
|
||||
* Base class for implementing repositories using Querydsl library.
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@@ -59,9 +58,8 @@ public abstract class QueryDslRepositorySupport {
|
||||
/**
|
||||
* Setter to inject {@link EntityManager}.
|
||||
*
|
||||
* @param entityManager must not be {@literal null}
|
||||
* @param entityManager must not be {@literal null}.
|
||||
*/
|
||||
@PersistenceContext
|
||||
public void setEntityManager(EntityManager entityManager) {
|
||||
|
||||
Assert.notNull(entityManager, "EntityManager must not be null!");
|
||||
|
||||
Reference in New Issue
Block a user