|
|
|
@ -19,6 +19,9 @@ import java.lang.reflect.Method; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.ResultSet; |
|
|
|
import java.sql.SQLException; |
|
|
|
import java.sql.SQLException; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
|
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.beans.factory.BeanFactory; |
|
|
|
import org.springframework.context.ApplicationEventPublisher; |
|
|
|
import org.springframework.context.ApplicationEventPublisher; |
|
|
|
import org.springframework.data.jdbc.core.convert.EntityRowMapper; |
|
|
|
import org.springframework.data.jdbc.core.convert.EntityRowMapper; |
|
|
|
@ -58,6 +61,8 @@ import org.springframework.util.Assert; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class JdbcQueryLookupStrategy implements QueryLookupStrategy { |
|
|
|
class JdbcQueryLookupStrategy implements QueryLookupStrategy { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static final Log LOG = LogFactory.getLog(JdbcQueryLookupStrategy.class); |
|
|
|
|
|
|
|
|
|
|
|
private final ApplicationEventPublisher publisher; |
|
|
|
private final ApplicationEventPublisher publisher; |
|
|
|
private final @Nullable EntityCallbacks callbacks; |
|
|
|
private final @Nullable EntityCallbacks callbacks; |
|
|
|
private final RelationalMappingContext context; |
|
|
|
private final RelationalMappingContext context; |
|
|
|
@ -103,6 +108,11 @@ class JdbcQueryLookupStrategy implements QueryLookupStrategy { |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (namedQueries.hasQuery(queryMethod.getNamedQueryName()) || queryMethod.hasAnnotatedQuery()) { |
|
|
|
if (namedQueries.hasQuery(queryMethod.getNamedQueryName()) || queryMethod.hasAnnotatedQuery()) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (queryMethod.hasAnnotatedQuery() && queryMethod.hasAnnotatedQueryName()) { |
|
|
|
|
|
|
|
LOG.warn(String.format( |
|
|
|
|
|
|
|
"Query method %s is annotated with both, a query and a query name. Using the declared query.", method)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RowMapper<?> mapper = queryMethod.isModifyingQuery() ? null : createMapper(queryMethod); |
|
|
|
RowMapper<?> mapper = queryMethod.isModifyingQuery() ? null : createMapper(queryMethod); |
|
|
|
StringBasedJdbcQuery query = new StringBasedJdbcQuery(queryMethod, operations, mapper, converter); |
|
|
|
StringBasedJdbcQuery query = new StringBasedJdbcQuery(queryMethod, operations, mapper, converter); |
|
|
|
query.setBeanFactory(beanfactory); |
|
|
|
query.setBeanFactory(beanfactory); |
|
|
|
|