Browse Source

Polishing.

Formatting.

Original pull request #2000
See #1998
pull/2065/head
Jens Schauder 7 months ago committed by Mark Paluch
parent
commit
5d3d38e8ef
No known key found for this signature in database
GPG Key ID: 55BC6374BAA9D973
  1. 46
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/AbstractDelegatingRowMapper.java
  2. 8
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/AbstractJdbcQuery.java
  3. 48
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/CallbackCapableRowMapper.java
  4. 28
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/ConvertingRowMapper.java
  5. 85
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/DefaultRowMapperFactory.java
  6. 14
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/PartTreeJdbcQuery.java
  7. 55
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/RowMapperFactory.java
  8. 6
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java
  9. 46
      spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java

46
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/AbstractDelegatingRowMapper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2025 the original author or authors. * Copyright 2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,32 +23,38 @@ import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
/** /**
* Abstract {@link RowMapper} that delegates the actual mapping logic to a {@link AbstractDelegatingRowMapper#delegate delegate} * Abstract {@link RowMapper} that delegates the actual mapping logic to a {@link AbstractDelegatingRowMapper#delegate
* delegate}
* *
* @author Mikhail Polivakha * @author Mikhail Polivakha
* @since 4.0
*/ */
public abstract class AbstractDelegatingRowMapper<T> implements RowMapper<T> { public abstract class AbstractDelegatingRowMapper<T> implements RowMapper<T> {
private final RowMapper<T> delegate; private final RowMapper<T> delegate;
protected AbstractDelegatingRowMapper(RowMapper<T> delegate) { protected AbstractDelegatingRowMapper(RowMapper<T> delegate) {
Assert.notNull(delegate, "Delegating RowMapper cannot be null");
this.delegate = delegate; Assert.notNull(delegate, "Delegating RowMapper cannot be null");
}
@Override this.delegate = delegate;
public T mapRow(ResultSet rs, int rowNum) throws SQLException { }
T intermediate = delegate.mapRow(rs, rowNum);
return postProcessMapping(intermediate);
}
/** @Override
* The post-processing callback for implementations. @Nullable
* public T mapRow(ResultSet rs, int rowNum) throws SQLException {
* @return the mapped entity after applying post-processing logic
*/ T intermediate = delegate.mapRow(rs, rowNum);
protected T postProcessMapping(@Nullable T object) { return postProcessMapping(intermediate);
return object; }
}
/**
* The post-processing callback for implementations.
*
* @return the mapped entity after applying post-processing logic
*/
@Nullable
protected T postProcessMapping(@Nullable T object) {
return object;
}
} }

8
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/AbstractJdbcQuery.java

@ -15,8 +15,6 @@
*/ */
package org.springframework.data.jdbc.repository.query; package org.springframework.data.jdbc.repository.query;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List; import java.util.List;
import java.util.function.Supplier; import java.util.function.Supplier;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -156,7 +154,7 @@ public abstract class AbstractJdbcQuery implements RepositoryQuery {
* @deprecated Use {@link org.springframework.data.jdbc.repository.query.RowMapperFactory} instead * @deprecated Use {@link org.springframework.data.jdbc.repository.query.RowMapperFactory} instead
*/ */
@Deprecated(forRemoval = true, since = "3.4.4") @Deprecated(forRemoval = true, since = "3.4.4")
public interface RowMapperFactory extends org.springframework.data.jdbc.repository.query.RowMapperFactory { } public interface RowMapperFactory extends org.springframework.data.jdbc.repository.query.RowMapperFactory {}
/** /**
* Delegating {@link RowMapper} that reads a row into {@code T} and converts it afterwards into {@code Object}. * Delegating {@link RowMapper} that reads a row into {@code T} and converts it afterwards into {@code Object}.
@ -166,8 +164,8 @@ public abstract class AbstractJdbcQuery implements RepositoryQuery {
* @deprecated use {@link org.springframework.data.jdbc.repository.query.ConvertingRowMapper} instead * @deprecated use {@link org.springframework.data.jdbc.repository.query.ConvertingRowMapper} instead
*/ */
@Deprecated(forRemoval = true, since = "3.4.4") @Deprecated(forRemoval = true, since = "3.4.4")
protected static class ConvertingRowMapper<T> extends protected static class ConvertingRowMapper<T>
org.springframework.data.jdbc.repository.query.ConvertingRowMapper { extends org.springframework.data.jdbc.repository.query.ConvertingRowMapper {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public ConvertingRowMapper(RowMapper<T> delegate, Converter<Object, Object> converter) { public ConvertingRowMapper(RowMapper<T> delegate, Converter<Object, Object> converter) {

48
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/CallbackCapableRowMapper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2025 the original author or authors. * Copyright 2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,35 +25,41 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* Delegating {@link RowMapper} implementation that applies post-processing logic * Delegating {@link RowMapper} implementation that applies post-processing logic after the
* after the {@link RowMapper#mapRow(ResultSet, int)}. In particular, it emits the * {@link RowMapper#mapRow(ResultSet, int)}. In particular, it emits the {@link AfterConvertEvent} event and invokes the
* {@link AfterConvertEvent} event and invokes the {@link AfterConvertCallback} callbacks. * {@link AfterConvertCallback} callbacks.
* *
* @author Mark Paluch * @author Mark Paluch
* @author Mikhail Polivakha * @author Mikhail Polivakha
* @since 4.0
*/ */
public class CallbackCapableRowMapper<T> extends AbstractDelegatingRowMapper<T> { public class CallbackCapableRowMapper<T> extends AbstractDelegatingRowMapper<T> {
private final ApplicationEventPublisher publisher; private final ApplicationEventPublisher publisher;
private final @Nullable EntityCallbacks callbacks; private final @Nullable EntityCallbacks callbacks;
public CallbackCapableRowMapper(RowMapper<T> delegate, ApplicationEventPublisher publisher, @Nullable EntityCallbacks callbacks) { public CallbackCapableRowMapper(RowMapper<T> delegate, ApplicationEventPublisher publisher,
super(delegate); @Nullable EntityCallbacks callbacks) {
this.publisher = publisher;
this.callbacks = callbacks;
}
@Override super(delegate);
public T postProcessMapping(@Nullable T object) {
if (object != null) {
publisher.publishEvent(new AfterConvertEvent<>(object)); this.publisher = publisher;
this.callbacks = callbacks;
}
if (callbacks != null) { @Override
return callbacks.callback(AfterConvertCallback.class, object); @Nullable
} public T postProcessMapping(@Nullable T object) {
} if (object != null) {
return object;
} publisher.publishEvent(new AfterConvertEvent<>(object));
if (callbacks != null) {
return callbacks.callback(AfterConvertCallback.class, object);
}
}
return object;
}
} }

28
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/ConvertingRowMapper.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2025 the original author or authors. * Copyright 2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -20,24 +20,26 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
/** /**
* Delegating {@link RowMapper} that reads a row into {@code T} and converts it afterwards into {@code Object}. * Delegating {@link RowMapper} that reads a row into {@code T} and converts it afterward into {@code Object}.
* *
* @author Mark Paluch * @author Mark Paluch
* @author Mikhail Polivakha * @author Mikhail Polivakha
* * @since 4.0
* @since 2.3
*/ */
public class ConvertingRowMapper extends AbstractDelegatingRowMapper<Object> { public class ConvertingRowMapper extends AbstractDelegatingRowMapper<Object> {
private final Converter<Object, Object> converter; private final Converter<Object, Object> converter;
public ConvertingRowMapper(RowMapper<Object> delegate, Converter<Object, Object> converter) {
super(delegate);
public ConvertingRowMapper(RowMapper<Object> delegate, Converter<Object, Object> converter) { this.converter = converter;
super(delegate); }
this.converter = converter;
}
@Override @Override
public Object postProcessMapping(@Nullable Object object) { @Nullable
return object != null ? converter.convert(object) : null; public Object postProcessMapping(@Nullable Object object) {
} return object != null ? converter.convert(object) : null;
}
} }

85
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/DefaultRowMapperFactory.java

@ -27,64 +27,63 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.SingleColumnRowMapper; import org.springframework.jdbc.core.SingleColumnRowMapper;
/** /**
* Default implementation of {@link RowMapperFactory}. Honors the custom mappings defined * Default implementation of {@link RowMapperFactory}. Honors the custom mappings defined in
* in {@link QueryMappingConfiguration}. * {@link QueryMappingConfiguration}.
* <p> * <p>
* This implementation is not capable of loading the {@link RowMapper} or {@link ResultSetExtractor} * This implementation is not capable of loading the {@link RowMapper} or {@link ResultSetExtractor} by reference via
* by reference via corresponding methods from {@link RowMapperFactory}. * corresponding methods from {@link RowMapperFactory}.
* *
* @implNote Public APIs of this class are thread-safe. * @implNote Public APIs of this class are thread-safe.
* @author Mikhail Polivakha * @author Mikhail Polivakha
* @since 4.0
*/ */
public class DefaultRowMapperFactory implements RowMapperFactory { public class DefaultRowMapperFactory implements RowMapperFactory {
private final RelationalMappingContext context; private final RelationalMappingContext context;
private final JdbcConverter converter; private final JdbcConverter converter;
private final QueryMappingConfiguration queryMappingConfiguration; private final QueryMappingConfiguration queryMappingConfiguration;
private final EntityCallbacks entityCallbacks; private final EntityCallbacks entityCallbacks;
private final ApplicationEventPublisher publisher; private final ApplicationEventPublisher publisher;
public DefaultRowMapperFactory( public DefaultRowMapperFactory(RelationalMappingContext context, JdbcConverter converter,
RelationalMappingContext context, QueryMappingConfiguration queryMappingConfiguration, EntityCallbacks entityCallbacks,
JdbcConverter converter, ApplicationEventPublisher publisher) {
QueryMappingConfiguration queryMappingConfiguration,
EntityCallbacks entityCallbacks,
ApplicationEventPublisher publisher
) {
this.context = context;
this.converter = converter;
this.queryMappingConfiguration = queryMappingConfiguration;
this.entityCallbacks = entityCallbacks;
this.publisher = publisher;
}
@Override this.context = context;
@SuppressWarnings("unchecked") this.converter = converter;
public RowMapper<Object> create(Class<?> returnedObjectType) { this.queryMappingConfiguration = queryMappingConfiguration;
this.entityCallbacks = entityCallbacks;
this.publisher = publisher;
}
RelationalPersistentEntity<?> persistentEntity = context.getPersistentEntity(returnedObjectType); @Override
@SuppressWarnings("unchecked")
public RowMapper<Object> create(Class<?> returnedObjectType) {
if (persistentEntity == null) { RelationalPersistentEntity<?> persistentEntity = context.getPersistentEntity(returnedObjectType);
return (RowMapper<Object>) SingleColumnRowMapper.newInstance(returnedObjectType,
converter.getConversionService());
}
return (RowMapper<Object>) determineDefaultMapper(returnedObjectType); if (persistentEntity == null) {
}
private RowMapper<?> determineDefaultMapper(Class<?> returnedObjectType) { return (RowMapper<Object>) SingleColumnRowMapper.newInstance(returnedObjectType,
converter.getConversionService());
}
RowMapper<?> configuredQueryMapper = queryMappingConfiguration.getRowMapper(returnedObjectType); return (RowMapper<Object>) determineDefaultMapper(returnedObjectType);
}
if (configuredQueryMapper != null) { private RowMapper<?> determineDefaultMapper(Class<?> returnedObjectType) {
return configuredQueryMapper;
}
EntityRowMapper<?> defaultEntityRowMapper = new EntityRowMapper<>( // RowMapper<?> configuredQueryMapper = queryMappingConfiguration.getRowMapper(returnedObjectType);
context.getRequiredPersistentEntity(returnedObjectType), //
converter //
);
return new CallbackCapableRowMapper<>(defaultEntityRowMapper, publisher, entityCallbacks); if (configuredQueryMapper != null) {
} return configuredQueryMapper;
}
EntityRowMapper<?> defaultEntityRowMapper = new EntityRowMapper<>( //
context.getRequiredPersistentEntity(returnedObjectType), //
converter //
);
return new CallbackCapableRowMapper<>(defaultEntityRowMapper, publisher, entityCallbacks);
}
} }

14
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/PartTreeJdbcQuery.java

@ -97,7 +97,8 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
* @since 2.3 * @since 2.3
*/ */
public PartTreeJdbcQuery(RelationalMappingContext context, JdbcQueryMethod queryMethod, Dialect dialect, public PartTreeJdbcQuery(RelationalMappingContext context, JdbcQueryMethod queryMethod, Dialect dialect,
JdbcConverter converter, NamedParameterJdbcOperations operations, org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory) { JdbcConverter converter, NamedParameterJdbcOperations operations,
org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory) {
super(queryMethod, operations); super(queryMethod, operations);
@ -160,13 +161,13 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
JdbcQueryExecution<?> queryExecution = getJdbcQueryExecution(extractor, rowMapper); JdbcQueryExecution<?> queryExecution = getJdbcQueryExecution(extractor, rowMapper);
if (getQueryMethod().isSliceQuery()) { if (getQueryMethod().isSliceQuery()) {
//noinspection unchecked // noinspection unchecked
return new SliceQueryExecution<>((JdbcQueryExecution<Collection<Object>>) queryExecution, accessor.getPageable()); return new SliceQueryExecution<>((JdbcQueryExecution<Collection<Object>>) queryExecution, accessor.getPageable());
} }
if (getQueryMethod().isPageQuery()) { if (getQueryMethod().isPageQuery()) {
//noinspection unchecked // noinspection unchecked
return new PageQueryExecution<>((JdbcQueryExecution<Collection<Object>>) queryExecution, accessor.getPageable(), return new PageQueryExecution<>((JdbcQueryExecution<Collection<Object>>) queryExecution, accessor.getPageable(),
() -> { () -> {
@ -291,7 +292,8 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
private final Lazy<RowMapper<?>> rowMapper; private final Lazy<RowMapper<?>> rowMapper;
private final Function<ResultProcessor, RowMapper<?>> rowMapperFunction; private final Function<ResultProcessor, RowMapper<?>> rowMapperFunction;
public CachedRowMapperFactory(PartTree tree, org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, RelationalConverter converter, public CachedRowMapperFactory(PartTree tree,
org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, RelationalConverter converter,
ResultProcessor defaultResultProcessor) { ResultProcessor defaultResultProcessor) {
this.rowMapperFunction = processor -> { this.rowMapperFunction = processor -> {
@ -301,8 +303,8 @@ public class PartTreeJdbcQuery extends AbstractJdbcQuery {
} }
Converter<Object, Object> resultProcessingConverter = new ResultProcessingConverter(processor, Converter<Object, Object> resultProcessingConverter = new ResultProcessingConverter(processor,
converter.getMappingContext(), converter.getEntityInstantiators()); converter.getMappingContext(), converter.getEntityInstantiators());
return new org.springframework.data.jdbc.repository.query.ConvertingRowMapper(rowMapperFactory.create(processor.getReturnedType().getDomainType()), return new org.springframework.data.jdbc.repository.query.ConvertingRowMapper(
resultProcessingConverter); rowMapperFactory.create(processor.getReturnedType().getDomainType()), resultProcessingConverter);
}; };
this.rowMapper = Lazy.of(() -> this.rowMapperFunction.apply(defaultResultProcessor)); this.rowMapper = Lazy.of(() -> this.rowMapperFunction.apply(defaultResultProcessor));

55
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/RowMapperFactory.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2020-2025 the original author or authors. * Copyright 2025 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,36 +23,35 @@ import org.springframework.jdbc.core.RowMapper;
* *
* @author Jens Schauder * @author Jens Schauder
* @author Mikhail Polivakha * @author Mikhail Polivakha
* * @since 4.0
* @since 2.3
*/ */
public interface RowMapperFactory { public interface RowMapperFactory {
/** /**
* Obtain a {@link RowMapper} based on the expected return type passed in as an argument. * Obtain a {@link RowMapper} based on the expected return type passed in as an argument.
* *
* @param result must not be {@code null}. * @param result must not be {@code null}.
* @return a {@code RowMapper} producing instances of {@code result}. * @return a {@code RowMapper} producing instances of {@code result}.
*/ */
RowMapper<Object> create(Class<?> result); RowMapper<Object> create(Class<?> result);
/** /**
* Obtain a {@link RowMapper} from some other source, typically a {@link org.springframework.beans.factory.BeanFactory}. * Obtain a {@link RowMapper} from some other source, typically a
* * {@link org.springframework.beans.factory.BeanFactory}.
* @param reference must not be {@code null}. *
* @since 3.4 * @param reference must not be {@code null}.
*/ */
default RowMapper<Object> getRowMapper(String reference) { default RowMapper<Object> getRowMapper(String reference) {
throw new UnsupportedOperationException("getRowMapper by reference is not supported"); throw new UnsupportedOperationException("getRowMapper by reference is not supported");
} }
/** /**
* Obtain a {@code ResultSetExtractor} from some other source, typically a {@link org.springframework.beans.factory.BeanFactory}. * Obtain a {@code ResultSetExtractor} from some other source, typically a
* * {@link org.springframework.beans.factory.BeanFactory}.
* @param reference must not be {@code null}. *
* @since 3.4 * @param reference must not be {@code null}.
*/ */
default ResultSetExtractor<Object> getResultSetExtractor(String reference) { default ResultSetExtractor<Object> getResultSetExtractor(String reference) {
throw new UnsupportedOperationException("getResultSetExtractor by reference is not supported"); throw new UnsupportedOperationException("getResultSetExtractor by reference is not supported");
} }
} }

6
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/query/StringBasedJdbcQuery.java

@ -95,7 +95,8 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
* @since 3.4 * @since 3.4
*/ */
public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations, public StringBasedJdbcQuery(JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations,
org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, JdbcConverter converter, ValueExpressionDelegate delegate) { org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, JdbcConverter converter,
ValueExpressionDelegate delegate) {
this(queryMethod.getRequiredQuery(), queryMethod, operations, rowMapperFactory, converter, delegate); this(queryMethod.getRequiredQuery(), queryMethod, operations, rowMapperFactory, converter, delegate);
} }
@ -112,7 +113,8 @@ public class StringBasedJdbcQuery extends AbstractJdbcQuery {
* @since 3.4 * @since 3.4
*/ */
public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations, public StringBasedJdbcQuery(String query, JdbcQueryMethod queryMethod, NamedParameterJdbcOperations operations,
org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, JdbcConverter converter, ValueExpressionDelegate delegate) { org.springframework.data.jdbc.repository.query.RowMapperFactory rowMapperFactory, JdbcConverter converter,
ValueExpressionDelegate delegate) {
super(queryMethod, operations); super(queryMethod, operations);
Assert.hasText(query, "Query must not be null or empty"); Assert.hasText(query, "Query must not be null or empty");
Assert.notNull(rowMapperFactory, "RowMapperFactory must not be null"); Assert.notNull(rowMapperFactory, "RowMapperFactory must not be null");

46
spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/support/JdbcQueryLookupStrategy.java

@ -109,10 +109,10 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations, QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations,
ValueExpressionDelegate delegate) { ValueExpressionDelegate delegate) {
super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, delegate);
delegate);
this.rowMapperFactory = new DefaultRowMapperFactory(getMappingContext(), getConverter(), getQueryMappingConfiguration(), getCallbacks(), getPublisher()); this.rowMapperFactory = new DefaultRowMapperFactory(getMappingContext(), getConverter(),
getQueryMappingConfiguration(), getCallbacks(), getPublisher());
} }
@Override @Override
@ -121,7 +121,8 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
JdbcQueryMethod queryMethod = getJdbcQueryMethod(method, repositoryMetadata, projectionFactory, namedQueries); JdbcQueryMethod queryMethod = getJdbcQueryMethod(method, repositoryMetadata, projectionFactory, namedQueries);
return new PartTreeJdbcQuery(getMappingContext(), queryMethod, getDialect(), getConverter(), getOperations(), rowMapperFactory); return new PartTreeJdbcQuery(getMappingContext(), queryMethod, getDialect(), getConverter(), getOperations(),
rowMapperFactory);
} }
} }
@ -140,10 +141,10 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
RelationalMappingContext context, JdbcConverter converter, Dialect dialect, RelationalMappingContext context, JdbcConverter converter, Dialect dialect,
QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations, QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations,
@Nullable BeanFactory beanfactory, ValueExpressionDelegate delegate) { @Nullable BeanFactory beanfactory, ValueExpressionDelegate delegate) {
super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, delegate);
delegate);
this.rowMapperFactory = new BeanFactoryAwareRowMapperFactory(context, converter, queryMappingConfiguration, callbacks, publisher, beanfactory); this.rowMapperFactory = new BeanFactoryAwareRowMapperFactory(context, converter, queryMappingConfiguration,
callbacks, publisher, beanfactory);
} }
@Override @Override
@ -192,11 +193,10 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
CreateIfNotFoundQueryLookupStrategy(ApplicationEventPublisher publisher, @Nullable EntityCallbacks callbacks, CreateIfNotFoundQueryLookupStrategy(ApplicationEventPublisher publisher, @Nullable EntityCallbacks callbacks,
RelationalMappingContext context, JdbcConverter converter, Dialect dialect, RelationalMappingContext context, JdbcConverter converter, Dialect dialect,
QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations, QueryMappingConfiguration queryMappingConfiguration, NamedParameterJdbcOperations operations,
CreateQueryLookupStrategy createStrategy, CreateQueryLookupStrategy createStrategy, DeclaredQueryLookupStrategy lookupStrategy,
DeclaredQueryLookupStrategy lookupStrategy, ValueExpressionDelegate delegate) { ValueExpressionDelegate delegate) {
super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, super(publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, delegate);
delegate);
Assert.notNull(createStrategy, "CreateQueryLookupStrategy must not be null"); Assert.notNull(createStrategy, "CreateQueryLookupStrategy must not be null");
Assert.notNull(lookupStrategy, "DeclaredQueryLookupStrategy must not be null"); Assert.notNull(lookupStrategy, "DeclaredQueryLookupStrategy must not be null");
@ -264,9 +264,9 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
return switch (keyToUse) { return switch (keyToUse) {
case CREATE -> createQueryLookupStrategy; case CREATE -> createQueryLookupStrategy;
case USE_DECLARED_QUERY -> declaredQueryLookupStrategy; case USE_DECLARED_QUERY -> declaredQueryLookupStrategy;
case CREATE_IF_NOT_FOUND -> new CreateIfNotFoundQueryLookupStrategy( case CREATE_IF_NOT_FOUND ->
publisher, callbacks, context, converter, dialect, queryMappingConfiguration, operations, new CreateIfNotFoundQueryLookupStrategy(publisher, callbacks, context, converter, dialect,
createQueryLookupStrategy, declaredQueryLookupStrategy, delegate); queryMappingConfiguration, operations, createQueryLookupStrategy, declaredQueryLookupStrategy, delegate);
}; };
} }
@ -278,15 +278,15 @@ abstract class JdbcQueryLookupStrategy extends RelationalQueryLookupStrategy {
return operations; return operations;
} }
QueryMappingConfiguration getQueryMappingConfiguration() { QueryMappingConfiguration getQueryMappingConfiguration() {
return queryMappingConfiguration; return queryMappingConfiguration;
} }
EntityCallbacks getCallbacks() { EntityCallbacks getCallbacks() {
return callbacks; return callbacks;
} }
ApplicationEventPublisher getPublisher() { ApplicationEventPublisher getPublisher() {
return publisher; return publisher;
} }
} }

Loading…
Cancel
Save