diff --git a/src/main/java/org/springframework/data/jpa/repository/config/BeanDefinitionNames.java b/src/main/java/org/springframework/data/jpa/repository/config/BeanDefinitionNames.java index 2fa664a98..2a24c3b15 100644 --- a/src/main/java/org/springframework/data/jpa/repository/config/BeanDefinitionNames.java +++ b/src/main/java/org/springframework/data/jpa/repository/config/BeanDefinitionNames.java @@ -19,6 +19,7 @@ package org.springframework.data.jpa.repository.config; * Helper class to manage bean definition names in a single place. * * @author Oliver Gierke + * @author Thomas Darimont */ interface BeanDefinitionNames { diff --git a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java index 9880228c1..0203c646b 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/JpaQueryLookupStrategy.java @@ -50,7 +50,6 @@ public final class JpaQueryLookupStrategy { private final EntityManager em; private final QueryExtractor provider; - private final EvaluationContextProvider evaluationContextProvider; /** * Creates a new {@link AbstractQueryLookupStrategy}. @@ -59,32 +58,21 @@ public final class JpaQueryLookupStrategy { * @param extractor * @param evaluationContextProvider */ - public AbstractQueryLookupStrategy(EntityManager em, QueryExtractor extractor, - EvaluationContextProvider evaluationContextProvider) { + public AbstractQueryLookupStrategy(EntityManager em, QueryExtractor extractor) { this.em = em; this.provider = extractor; - this.evaluationContextProvider = evaluationContextProvider; } /* * (non-Javadoc) - * - * @see org.springframework.data.repository.query.QueryLookupStrategy# - * resolveQuery(java.lang.reflect.Method, - * org.springframework.data.repository.core.RepositoryMetadata, - * org.springframework.data.repository.core.NamedQueries) + * @see org.springframework.data.repository.query.QueryLookupStrategy#resolveQuery(java.lang.reflect.Method, org.springframework.data.repository.core.RepositoryMetadata, org.springframework.data.repository.core.NamedQueries) */ public final RepositoryQuery resolveQuery(Method method, RepositoryMetadata metadata, NamedQueries namedQueries) { - return resolveQuery(new JpaQueryMethod(method, metadata, provider), em, namedQueries); } protected abstract RepositoryQuery resolveQuery(JpaQueryMethod method, EntityManager em, NamedQueries namedQueries); - - protected EvaluationContextProvider getEvaluationContextProvider() { - return evaluationContextProvider; - } } /** @@ -95,10 +83,8 @@ public final class JpaQueryLookupStrategy { */ private static class CreateQueryLookupStrategy extends AbstractQueryLookupStrategy { - public CreateQueryLookupStrategy(EntityManager em, QueryExtractor extractor, - EvaluationContextProvider evaluationContextProvider) { - - super(em, extractor, evaluationContextProvider); + public CreateQueryLookupStrategy(EntityManager em, QueryExtractor extractor) { + super(em, extractor); } @Override @@ -123,6 +109,8 @@ public final class JpaQueryLookupStrategy { */ private static class DeclaredQueryLookupStrategy extends AbstractQueryLookupStrategy { + private final EvaluationContextProvider evaluationContextProvider; + /** * Creates a new {@link DeclaredQueryLookupStrategy}. * @@ -133,13 +121,18 @@ public final class JpaQueryLookupStrategy { public DeclaredQueryLookupStrategy(EntityManager em, QueryExtractor extractor, EvaluationContextProvider evaluationContextProvider) { - super(em, extractor, evaluationContextProvider); + super(em, extractor); + this.evaluationContextProvider = evaluationContextProvider; } + /* + * (non-Javadoc) + * @see org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy.AbstractQueryLookupStrategy#resolveQuery(org.springframework.data.jpa.repository.query.JpaQueryMethod, javax.persistence.EntityManager, org.springframework.data.repository.core.NamedQueries) + */ @Override protected RepositoryQuery resolveQuery(JpaQueryMethod method, EntityManager em, NamedQueries namedQueries) { - RepositoryQuery query = JpaQueryFactory.INSTANCE.fromQueryAnnotation(method, em, getEvaluationContextProvider()); + RepositoryQuery query = JpaQueryFactory.INSTANCE.fromQueryAnnotation(method, em, evaluationContextProvider); if (null != query) { return query; @@ -154,7 +147,7 @@ public final class JpaQueryLookupStrategy { String name = method.getNamedQueryName(); if (namedQueries.hasQuery(name)) { return JpaQueryFactory.INSTANCE.fromMethodWithQueryString(method, em, namedQueries.getQuery(name), - getEvaluationContextProvider()); + evaluationContextProvider); } query = NamedQuery.lookupFrom(method, em); @@ -191,15 +184,18 @@ public final class JpaQueryLookupStrategy { * @param evaluationContextProvider */ public CreateIfNotFoundQueryLookupStrategy(EntityManager em, QueryExtractor extractor, - CreateQueryLookupStrategy createStrategy, DeclaredQueryLookupStrategy lookupStrategy, - EvaluationContextProvider evaluationContextProvider) { + CreateQueryLookupStrategy createStrategy, DeclaredQueryLookupStrategy lookupStrategy) { - super(em, extractor, evaluationContextProvider); + super(em, extractor); this.createStrategy = createStrategy; this.lookupStrategy = lookupStrategy; } + /* + * (non-Javadoc) + * @see org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy.AbstractQueryLookupStrategy#resolveQuery(org.springframework.data.jpa.repository.query.JpaQueryMethod, javax.persistence.EntityManager, org.springframework.data.repository.core.NamedQueries) + */ @Override protected RepositoryQuery resolveQuery(JpaQueryMethod method, EntityManager em, NamedQueries namedQueries) { @@ -229,13 +225,12 @@ public final class JpaQueryLookupStrategy { switch (key != null ? key : Key.CREATE_IF_NOT_FOUND) { case CREATE: - return new CreateQueryLookupStrategy(em, extractor, evaluationContextProvider); + return new CreateQueryLookupStrategy(em, extractor); case USE_DECLARED_QUERY: return new DeclaredQueryLookupStrategy(em, extractor, evaluationContextProvider); case CREATE_IF_NOT_FOUND: - return new CreateIfNotFoundQueryLookupStrategy(em, extractor, new CreateQueryLookupStrategy(em, extractor, - evaluationContextProvider), new DeclaredQueryLookupStrategy(em, extractor, evaluationContextProvider), - evaluationContextProvider); + return new CreateIfNotFoundQueryLookupStrategy(em, extractor, new CreateQueryLookupStrategy(em, extractor), + new DeclaredQueryLookupStrategy(em, extractor, evaluationContextProvider)); default: throw new IllegalArgumentException(String.format("Unsupported query lookup strategy %s!", key)); } diff --git a/src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java b/src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java index 3c104346e..2d4f38650 100644 --- a/src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java +++ b/src/main/java/org/springframework/data/jpa/repository/query/ParameterBinder.java @@ -127,19 +127,6 @@ public class ParameterBinder { return parameter.isBindable(); } - /** - * Computes the value to bind for the given {@link JpaParameter} and the given {@code value} by potentially using the - * other {@code values}. This is intended to be customized in sub-classes. - * - * @param parameter - * @param value - * @param values - * @return - */ - private Object computeParameterValue(JpaParameter parameter, Object value, Object[] values) { - return value; - } - /** * Perform the actual query parameter binding. * diff --git a/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java b/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java index 9d8f5606b..32be5ba8b 100644 --- a/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java +++ b/src/main/java/org/springframework/data/jpa/util/BeanDefinitionUtils.java @@ -126,6 +126,8 @@ public class BeanDefinitionUtils { } /** + * Value object to represent a {@link BeanDefinition} for an {@link EntityManagerFactory} with a dedicated bean name. + * * @author Oliver Gierke * @author Thomas Darimont */ @@ -143,19 +145,35 @@ public class BeanDefinitionUtils { * @param beanDefinition */ public EntityManagerFactoryBeanDefinition(String beanName, BeanFactory beanFactory, BeanDefinition beanDefinition) { + this.beanName = beanName; this.beanFactory = beanFactory; this.beanDefinition = beanDefinition; } + /** + * Returns the bean name of the {@link BeanDefinition} for the {@link EntityManagerFactory}. + * + * @return + */ public String getBeanName() { return beanName; } + /** + * Returns the underlying {@link BeanFactory}. + * + * @return + */ public BeanFactory getBeanFactory() { return beanFactory; } + /** + * Returns the {@link BeanDefinition} for the {@link EntityManagerFactory}. + * + * @return + */ public BeanDefinition getBeanDefinition() { return beanDefinition; }