Polishing.

Formatting.

Original pull request #1893
See #1006
This commit is contained in:
Jens Schauder
2025-05-14 17:05:27 +02:00
committed by Mark Paluch
parent 78f433608e
commit 563f8bb0a8
27 changed files with 193 additions and 168 deletions

View File

@@ -15,10 +15,7 @@
*/
package org.springframework.data.jdbc.core.convert;
import java.util.Optional;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
/**

View File

@@ -73,7 +73,6 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
private final NamedParameterJdbcOperations operations;
private final SqlParametersFactory sqlParametersFactory;
private final InsertStrategyFactory insertStrategyFactory;
private final QueryMappingConfiguration queryMappingConfiguration;
/**
@@ -451,6 +450,7 @@ public class DefaultDataAccessStrategy implements DataAccessStrategy {
}
private <T> RowMapper<? extends T> getRowMapper(Class<T> domainType) {
RowMapper<? extends T> targetRowMapper;
if ((targetRowMapper = queryMappingConfiguration.getRowMapper(domainType)) != null) {

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.data.jdbc.core.convert;
import org.springframework.jdbc.core.RowMapper;
@@ -9,7 +24,7 @@ import org.springframework.lang.Nullable;
*
* @author Jens Schauder
* @author Evgeni Dimitrov
* @since 1.1
* @since 4.0
*/
public interface QueryMappingConfiguration {

View File

@@ -32,7 +32,6 @@ import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jdbc.core.convert.*;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.mapping.PersistentPropertyPath;
import org.springframework.data.mapping.PropertyPath;
import org.springframework.data.relational.core.conversion.IdValueSource;
@@ -77,8 +76,8 @@ public class MyBatisDataAccessStrategy implements DataAccessStrategy {
* uses a {@link DefaultDataAccessStrategy}
*/
public static DataAccessStrategy createCombinedAccessStrategy(RelationalMappingContext context,
JdbcConverter converter, NamedParameterJdbcOperations operations, SqlSession sqlSession,
Dialect dialect, QueryMappingConfiguration queryMappingConfiguration) {
JdbcConverter converter, NamedParameterJdbcOperations operations, SqlSession sqlSession, Dialect dialect,
QueryMappingConfiguration queryMappingConfiguration) {
return createCombinedAccessStrategy(context, converter, operations, sqlSession, NamespaceStrategy.DEFAULT_INSTANCE,
dialect, queryMappingConfiguration);
}

View File

@@ -25,7 +25,6 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
@@ -42,7 +41,6 @@ import org.springframework.data.jdbc.core.dialect.JdbcArrayColumns;
import org.springframework.data.jdbc.core.dialect.JdbcDialect;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.core.mapping.JdbcSimpleTypes;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.relational.RelationalManagedTypes;
import org.springframework.data.relational.core.conversion.RelationalConverter;
@@ -229,8 +227,7 @@ public class AbstractJdbcConfiguration implements ApplicationContextAware {
SqlGeneratorSource sqlGeneratorSource = new SqlGeneratorSource(context, jdbcConverter, dialect);
DataAccessStrategyFactory factory = new DataAccessStrategyFactory(sqlGeneratorSource, jdbcConverter, operations,
new SqlParametersFactory(context, jdbcConverter), new InsertStrategyFactory(operations, dialect),
this.queryMappingConfiguration
);
this.queryMappingConfiguration);
return factory.create();
}
@@ -254,7 +251,8 @@ public class AbstractJdbcConfiguration implements ApplicationContextAware {
this.applicationContext = applicationContext;
}
public void setQueryMappingConfiguration(Optional<QueryMappingConfiguration> queryMappingConfiguration) throws BeansException {
public void setQueryMappingConfiguration(Optional<QueryMappingConfiguration> queryMappingConfiguration)
throws BeansException {
this.queryMappingConfiguration = queryMappingConfiguration.orElse(QueryMappingConfiguration.EMPTY);
}

View File

@@ -23,9 +23,9 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.mybatis.MyBatisDataAccessStrategy;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.relational.core.dialect.Dialect;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
@@ -48,6 +48,7 @@ public class MyBatisJdbcConfiguration extends AbstractJdbcConfiguration {
public DataAccessStrategy dataAccessStrategyBean(NamedParameterJdbcOperations operations, JdbcConverter jdbcConverter,
JdbcMappingContext context, Dialect dialect) {
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, jdbcConverter, operations, session, dialect, queryMappingConfiguration.orElse(QueryMappingConfiguration.EMPTY));
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, jdbcConverter, operations, session, dialect,
queryMappingConfiguration.orElse(QueryMappingConfiguration.EMPTY));
}
}

View File

@@ -28,9 +28,8 @@ import org.springframework.jdbc.core.RowMapper;
import org.springframework.lang.Nullable;
/**
* This {@link RowMapperFactory} implementation extends the {@link DefaultRowMapperFactory}
* by adding the capabilities to load {@link RowMapper} or {@link ResultSetExtractor} beans by
* their names in {@link BeanFactory}.
* This {@link RowMapperFactory} implementation extends the {@link DefaultRowMapperFactory} by adding the capabilities
* to load {@link RowMapper} or {@link ResultSetExtractor} beans by their names in {@link BeanFactory}.
*
* @author Mark Paluch
* @author Jens Schauder
@@ -39,38 +38,36 @@ import org.springframework.lang.Nullable;
@SuppressWarnings("unchecked")
public class BeanFactoryAwareRowMapperFactory extends DefaultRowMapperFactory {
private final @Nullable BeanFactory beanFactory;
private final @Nullable BeanFactory beanFactory;
public BeanFactoryAwareRowMapperFactory(
RelationalMappingContext context,
JdbcConverter converter,
QueryMappingConfiguration queryMappingConfiguration,
EntityCallbacks entityCallbacks,
ApplicationEventPublisher publisher,
@Nullable BeanFactory beanFactory
) {
super(context, converter, queryMappingConfiguration, entityCallbacks, publisher);
public BeanFactoryAwareRowMapperFactory(RelationalMappingContext context, JdbcConverter converter,
QueryMappingConfiguration queryMappingConfiguration, EntityCallbacks entityCallbacks,
ApplicationEventPublisher publisher, @Nullable BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
super(context, converter, queryMappingConfiguration, entityCallbacks, publisher);
@Override
public RowMapper<Object> getRowMapper(String reference) {
if (beanFactory == null) {
throw new IllegalStateException(
"Cannot resolve RowMapper bean reference '" + reference + "'; BeanFactory is not configured.");
}
this.beanFactory = beanFactory;
}
return beanFactory.getBean(reference, RowMapper.class);
}
@Override
public RowMapper<Object> getRowMapper(String reference) {
@Override
public ResultSetExtractor<Object> getResultSetExtractor(String reference) {
if (beanFactory == null) {
throw new IllegalStateException(
"Cannot resolve ResultSetExtractor bean reference '" + reference + "'; BeanFactory is not configured.");
}
if (beanFactory == null) {
throw new IllegalStateException(
"Cannot resolve RowMapper bean reference '" + reference + "'; BeanFactory is not configured.");
}
return beanFactory.getBean(reference, ResultSetExtractor.class);
}
return beanFactory.getBean(reference, RowMapper.class);
}
@Override
public ResultSetExtractor<Object> getResultSetExtractor(String reference) {
if (beanFactory == null) {
throw new IllegalStateException(
"Cannot resolve ResultSetExtractor bean reference '" + reference + "'; BeanFactory is not configured.");
}
return beanFactory.getBean(reference, ResultSetExtractor.class);
}
}

View File

@@ -124,8 +124,7 @@ public class JdbcRepositoryFactory extends RepositoryFactorySupport {
RelationalPersistentEntity<?> persistentEntity = context
.getRequiredPersistentEntity(repositoryInformation.getDomainType());
return getTargetRepositoryViaReflection(repositoryInformation, template, persistentEntity,
converter);
return getTargetRepositoryViaReflection(repositoryInformation, template, persistentEntity, converter);
}
@Override

View File

@@ -25,9 +25,9 @@ import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
import org.springframework.data.jdbc.core.convert.DataAccessStrategyFactory;
import org.springframework.data.jdbc.core.convert.InsertStrategyFactory;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.convert.SqlGeneratorSource;
import org.springframework.data.jdbc.core.convert.SqlParametersFactory;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.mapping.callback.EntityCallbacks;
import org.springframework.data.relational.core.dialect.Dialect;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;

View File

@@ -61,10 +61,10 @@ public class DependencyTests {
JavaClasses importedClasses = new ClassFileImporter().withImportOption(ImportOption.Predefined.DO_NOT_INCLUDE_TESTS)
.importPackages( //
"org.springframework.data.jdbc", // Spring Data Relational
"org.springframework.data.jdbc", // Spring Data JDBC
"org.springframework.data.relational", // Spring Data Relational
"org.springframework.data" // Spring Data Commons
)
).that(onlySpringData()) //
.that(ignore(AuditingHandlerBeanDefinitionParser.class)) //
.that(ignorePackage("org.springframework.data.aot.hint")) // ignoring aot, since it causes cycles in commons
.that(ignorePackage("org.springframework.data.aot")); // ignoring aot, since it causes cycles in commons

View File

@@ -67,8 +67,9 @@ class DefaultDataAccessStrategyUnitTests {
converter, //
namedJdbcOperations, //
sqlParametersFactory, //
insertStrategyFactory,
QueryMappingConfiguration.EMPTY).create();
insertStrategyFactory, //
QueryMappingConfiguration.EMPTY //
).create();
relationResolver.setDelegate(accessStrategy);

View File

@@ -15,7 +15,9 @@
*/
package org.springframework.data.jdbc.mybatis;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.*;
import junit.framework.AssertionFailedError;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSession;
@@ -29,8 +31,8 @@ import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.dialect.JdbcHsqlDbDialect;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.dialect.JdbcHsqlDbDialect;
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
import org.springframework.data.jdbc.testing.DatabaseType;
import org.springframework.data.jdbc.testing.EnabledOnDatabase;
@@ -42,8 +44,6 @@ import org.springframework.data.repository.CrudRepository;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import junit.framework.AssertionFailedError;
/**
* Tests the integration with Mybatis.
*

View File

@@ -31,92 +31,91 @@ import org.springframework.jdbc.core.RowMapper;
@IntegrationTest
public class PartTreeQueryMappingConfigurationIntegrationTests {
@Configuration
@Import(TestConfiguration.class)
@EnableJdbcRepositories(
considerNestedRepositories = true,
includeFilters = @ComponentScan.Filter(value = CarRepository.class, type = FilterType.ASSIGNABLE_TYPE))
static class Config {
@Configuration
@Import(TestConfiguration.class)
@EnableJdbcRepositories(considerNestedRepositories = true,
includeFilters = @ComponentScan.Filter(value = CarRepository.class, type = FilterType.ASSIGNABLE_TYPE))
static class Config {
@Bean
QueryMappingConfiguration mappers(@Qualifier("CustomRowMapperBean") CustomRowMapperBean rowMapperBean) {
return new DefaultQueryMappingConfiguration().registerRowMapper(Car.class, rowMapperBean);
}
@Bean
QueryMappingConfiguration mappers(@Qualifier("CustomRowMapperBean") CustomRowMapperBean rowMapperBean) {
return new DefaultQueryMappingConfiguration().registerRowMapper(Car.class, rowMapperBean);
}
@Bean(value = "CustomRowMapperBean")
public CustomRowMapperBean rowMapperBean() {
return new CustomRowMapperBean();
}
}
@Bean(value = "CustomRowMapperBean")
public CustomRowMapperBean rowMapperBean() {
return new CustomRowMapperBean();
}
}
@Autowired
private CarRepository carRepository;
@Autowired private CarRepository carRepository;
@Test // DATAJDBC-1006
void testCustomQueryMappingConfiguration_predefinedPartTreeQuery() {
@Test // DATAJDBC-1006
void testCustomQueryMappingConfiguration_predefinedPartTreeQuery() {
// given
Car saved = carRepository.save(new Car(null, "test-model"));
// given
Car saved = carRepository.save(new Car(null, "test-model"));
// when
Optional<Car> found = carRepository.findById(saved.getId());
// when
Optional<Car> found = carRepository.findById(saved.getId());
// then
Assertions.assertThat(found).isPresent().hasValueSatisfying(car -> Assertions.assertThat(car.getModel()).isEqualTo("STUB"));
}
// then
Assertions.assertThat(found).isPresent()
.hasValueSatisfying(car -> Assertions.assertThat(car.getModel()).isEqualTo("STUB"));
}
@Test // DATAJDBC-1006
void testCustomQueryMappingConfiguration_customPartTreeQuery() {
@Test // DATAJDBC-1006
void testCustomQueryMappingConfiguration_customPartTreeQuery() {
// given
Car saved = carRepository.save(new Car(null, "test-model"));
// given
Car saved = carRepository.save(new Car(null, "test-model"));
// when
Optional<Car> found = carRepository.findOneByModel("test-model");
// when
Optional<Car> found = carRepository.findOneByModel("test-model");
// then
Assertions.assertThat(found).isPresent().hasValueSatisfying(car -> Assertions.assertThat(car.getModel()).isEqualTo("STUB"));
}
// then
Assertions.assertThat(found).isPresent()
.hasValueSatisfying(car -> Assertions.assertThat(car.getModel()).isEqualTo("STUB"));
}
public static class CustomRowMapperBean implements RowMapper<Car> {
public static class CustomRowMapperBean implements RowMapper<Car> {
@Override
public Car mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Car(rs.getLong("id"), "STUB");
}
}
@Override
public Car mapRow(ResultSet rs, int rowNum) throws SQLException {
return new Car(rs.getLong("id"), "STUB");
}
}
interface CarRepository extends CrudRepository<Car, Long> {
interface CarRepository extends CrudRepository<Car, Long> {
Optional<Car> findOneByModel(String model);
}
Optional<Car> findOneByModel(String model);
}
public static class Car {
public static class Car {
@Id
private Long id;
private String model;
@Id private Long id;
private String model;
public Car(Long id, String model) {
this.id = id;
this.model = model;
}
public Car(Long id, String model) {
this.id = id;
this.model = model;
}
public Long getId() {
return this.id;
}
public Long getId() {
return this.id;
}
public String getModel() {
return this.model;
}
public String getModel() {
return this.model;
}
public void setId(Long id) {
this.id = id;
}
public void setId(Long id) {
this.id = id;
}
public void setModel(String model) {
this.model = model;
}
}
public void setModel(String model) {
this.model = model;
}
}
}

View File

@@ -15,16 +15,11 @@
*/
package org.springframework.data.jdbc.repository;
import static java.util.Arrays.asList;
import static org.assertj.core.api.Assertions.assertThat;
import static java.util.Arrays.*;
import static org.assertj.core.api.Assertions.*;
import static org.assertj.core.groups.Tuple.tuple;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -38,7 +33,6 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.convert.*;
import org.springframework.data.jdbc.core.dialect.JdbcH2Dialect;
import org.springframework.data.jdbc.core.dialect.JdbcHsqlDbDialect;
@@ -65,7 +59,6 @@ import org.springframework.jdbc.support.KeyHolder;
import org.springframework.lang.Nullable;
import org.springframework.util.ObjectUtils;
/**
* Unit tests for application events via {@link SimpleJdbcRepository}.
*

View File

@@ -61,7 +61,7 @@ public class StringBasedJdbcQueryMappingConfigurationIntegrationTests {
static class Config {
@Bean
QueryMappingConfiguration mappers() {
QueryMappingConfiguration mappers() {
return new DefaultQueryMappingConfiguration();
}

View File

@@ -38,9 +38,9 @@ import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
import org.springframework.data.jdbc.core.convert.DataAccessStrategyFactory;
import org.springframework.data.jdbc.core.convert.InsertStrategyFactory;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.convert.SqlGeneratorSource;
import org.springframework.data.jdbc.core.convert.SqlParametersFactory;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactoryBean;
import org.springframework.data.jdbc.testing.IntegrationTest;
import org.springframework.data.jdbc.testing.TestConfiguration;
@@ -168,8 +168,8 @@ public class EnableJdbcRepositoriesIntegrationTests {
@Qualifier("namedParameterJdbcTemplate") NamedParameterJdbcOperations template,
RelationalMappingContext context, JdbcConverter converter, Dialect dialect) {
return new DataAccessStrategyFactory(new SqlGeneratorSource(context, converter, dialect), converter, template,
new SqlParametersFactory(context, converter),
new InsertStrategyFactory(template, dialect), QueryMappingConfiguration.EMPTY).create();
new SqlParametersFactory(context, converter), new InsertStrategyFactory(template, dialect),
QueryMappingConfiguration.EMPTY).create();
}
@Bean

View File

@@ -30,13 +30,12 @@ import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.data.jdbc.core.convert.JdbcConverter;
import org.springframework.data.jdbc.core.dialect.JdbcH2Dialect;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.dialect.JdbcH2Dialect;
import org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration;
import org.springframework.data.jdbc.repository.query.Query;
import org.springframework.data.mapping.callback.EntityCallbacks;
import org.springframework.data.projection.ProjectionFactory;
import org.springframework.data.relational.core.dialect.H2Dialect;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.repository.core.NamedQueries;
import org.springframework.data.repository.core.RepositoryMetadata;
@@ -123,9 +122,9 @@ class JdbcQueryLookupStrategyUnitTests {
assertThatThrownBy(
() -> getRepositoryQuery(QueryLookupStrategy.Key.USE_DECLARED_QUERY, "findByName", mappingConfiguration))
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Did neither find a NamedQuery nor an annotated query for method")
.hasMessageContaining("findByName");
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("Did neither find a NamedQuery nor an annotated query for method")
.hasMessageContaining("findByName");
}
@ParameterizedTest

View File

@@ -37,8 +37,8 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.jdbc.core.convert.DataAccessStrategy;
import org.springframework.data.jdbc.core.convert.DefaultDataAccessStrategy;
import org.springframework.data.jdbc.core.convert.MappingJdbcConverter;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.relational.core.dialect.Dialect;
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
import org.springframework.data.repository.CrudRepository;

View File

@@ -24,7 +24,6 @@ import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mockito.Mockito;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -41,7 +40,6 @@ import org.springframework.data.jdbc.core.dialect.JdbcArrayColumns;
import org.springframework.data.jdbc.core.dialect.JdbcDialect;
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
import org.springframework.data.jdbc.core.mapping.JdbcSimpleTypes;
import org.springframework.data.jdbc.core.convert.QueryMappingConfiguration;
import org.springframework.data.jdbc.repository.config.DialectResolver;
import org.springframework.data.jdbc.repository.support.JdbcRepositoryFactory;
import org.springframework.data.mapping.callback.EntityCallback;
@@ -79,14 +77,10 @@ public class TestConfiguration {
public static final String PROFILE_SINGLE_QUERY_LOADING = "singleQueryLoading";
public static final String PROFILE_NO_SINGLE_QUERY_LOADING = "!" + PROFILE_SINGLE_QUERY_LOADING;
@Autowired
DataSource dataSource;
@Autowired
BeanFactory beanFactory;
@Autowired
ApplicationEventPublisher publisher;
@Autowired(required = false)
SqlSessionFactory sqlSessionFactory;
@Autowired DataSource dataSource;
@Autowired BeanFactory beanFactory;
@Autowired ApplicationEventPublisher publisher;
@Autowired(required = false) SqlSessionFactory sqlSessionFactory;
@Bean
JdbcRepositoryFactory jdbcRepositoryFactory(
@@ -122,7 +116,8 @@ public class TestConfiguration {
JdbcConverter converter, Dialect dialect, Optional<QueryMappingConfiguration> queryMappingConfiguration) {
return new DataAccessStrategyFactory(new SqlGeneratorSource(context, converter, dialect), converter, template,
new SqlParametersFactory(context, converter), new InsertStrategyFactory(template, dialect), queryMappingConfiguration.orElse(QueryMappingConfiguration.EMPTY)).create();
new SqlParametersFactory(context, converter), new InsertStrategyFactory(template, dialect),
queryMappingConfiguration.orElse(QueryMappingConfiguration.EMPTY)).create();
}
@Bean("jdbcMappingContext")
@@ -149,9 +144,8 @@ public class TestConfiguration {
@Bean
CustomConversions jdbcCustomConversions(Dialect dialect) {
SimpleTypeHolder simpleTypeHolder = dialect.simpleTypes().isEmpty() ?
JdbcSimpleTypes.HOLDER :
new SimpleTypeHolder(dialect.simpleTypes(), JdbcSimpleTypes.HOLDER);
SimpleTypeHolder simpleTypeHolder = dialect.simpleTypes().isEmpty() ? JdbcSimpleTypes.HOLDER
: new SimpleTypeHolder(dialect.simpleTypes(), JdbcSimpleTypes.HOLDER);
return new JdbcCustomConversions(CustomConversions.StoreConversions.of(simpleTypeHolder, storeConverters(dialect)),
Collections.emptyList());
@@ -171,9 +165,8 @@ public class TestConfiguration {
Dialect dialect) {
org.springframework.data.jdbc.core.dialect.JdbcArrayColumns arrayColumns = dialect instanceof JdbcDialect
?
((JdbcDialect) dialect).getArraySupport() :
JdbcArrayColumns.DefaultSupport.INSTANCE;
? ((JdbcDialect) dialect).getArraySupport()
: JdbcArrayColumns.DefaultSupport.INSTANCE;
return new MappingJdbcConverter( //
mappingContext, //

View File

@@ -1,3 +1,7 @@
DROP TABLE car;
CREATE TABLE car ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, model VARCHAR(100));
CREATE TABLE car
(
id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
model VARCHAR(100)
);

View File

@@ -1,4 +1,8 @@
DROP TABLE car;
CREATE TABLE car ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, model VARCHAR(100));
CREATE TABLE car
(
id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
model VARCHAR(100)
);

View File

@@ -1 +1,5 @@
CREATE TABLE car ( id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY, model VARCHAR(100));
CREATE TABLE car
(
id BIGINT GENERATED BY DEFAULT AS IDENTITY ( START WITH 1 ) PRIMARY KEY,
model VARCHAR(100)
);

View File

@@ -1 +1,6 @@
CREATE TABLE car ( id INT NOT NULL AUTO_INCREMENT, model VARCHAR(100), PRIMARY KEY (id));
CREATE TABLE car
(
id INT NOT NULL AUTO_INCREMENT,
model VARCHAR(100),
PRIMARY KEY (id)
);

View File

@@ -1,2 +1,6 @@
DROP TABLE IF EXISTS car;
CREATE TABLE car ( id int IDENTITY(1,1) PRIMARY KEY, model VARCHAR(100));
CREATE TABLE car
(
id int IDENTITY(1,1) PRIMARY KEY,
model VARCHAR(100)
);

View File

@@ -1 +1,6 @@
CREATE TABLE car ( id INT NOT NULL AUTO_INCREMENT, model VARCHAR(100), PRIMARY KEY (id));
CREATE TABLE car
(
id INT NOT NULL AUTO_INCREMENT,
model VARCHAR(100),
PRIMARY KEY (id)
);

View File

@@ -1,2 +1,6 @@
DROP TABLE CAR;
CREATE TABLE CAR ( id NUMBER GENERATED by default on null as IDENTITY PRIMARY KEY, model VARCHAR(100));
CREATE TABLE CAR
(
id NUMBER GENERATED by default on null as IDENTITY PRIMARY KEY,
model VARCHAR(100)
);

View File

@@ -1,2 +1,6 @@
DROP TABLE car;
CREATE TABLE car ( id SERIAL PRIMARY KEY, model VARCHAR(100));
CREATE TABLE car
(
id SERIAL PRIMARY KEY,
model VARCHAR(100)
);