DATAJDBC-137 - Polishing.
Moved the dependency to NamedParameterJdbcOperations out of JdbcMappingContext. This revealed that despite the DataAccessStrategy abstraction, there are a couple of places in the query execution subsystem that work with a plain NamedParameterJdbcOperations instance, so that we now have to carry that around all the way from the repository factory bean. Improving that is subject for further changes. A bit of JavaDoc and generics polish here and there.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.jdbc.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -26,7 +27,6 @@ import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
import org.springframework.jdbc.support.KeyHolder;
|
||||
@@ -42,14 +42,12 @@ public class DefaultDataAccessStrategyUnitTests {
|
||||
public static final long ORIGINAL_ID = 4711L;
|
||||
|
||||
NamedParameterJdbcOperations jdbcOperations = mock(NamedParameterJdbcOperations.class);
|
||||
JdbcMappingContext context = new JdbcMappingContext(NamingStrategy.INSTANCE, jdbcOperations, __ -> {});
|
||||
JdbcMappingContext context = new JdbcMappingContext();
|
||||
HashMap<String, Object> additionalParameters = new HashMap<>();
|
||||
ArgumentCaptor<SqlParameterSource> paramSourceCaptor = ArgumentCaptor.forClass(SqlParameterSource.class);
|
||||
|
||||
DefaultDataAccessStrategy accessStrategy = new DefaultDataAccessStrategy( //
|
||||
new SqlGeneratorSource(context), //
|
||||
context //
|
||||
);
|
||||
DefaultDataAccessStrategy accessStrategy = new DefaultDataAccessStrategy(new SqlGeneratorSource(context), context,
|
||||
jdbcOperations);
|
||||
|
||||
@Test // DATAJDBC-146
|
||||
public void additionalParameterForIdDoesNotLeadToDuplicateParameters() {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package org.springframework.data.jdbc.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.AbstractMap.SimpleEntry;
|
||||
@@ -30,7 +31,6 @@ import org.springframework.data.jdbc.core.conversion.JdbcPropertyPath;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link DefaultJdbcInterpreter}
|
||||
@@ -47,7 +47,7 @@ public class DefaultJdbcInterpreterUnitTests {
|
||||
public String getReverseColumnName(JdbcPersistentProperty property) {
|
||||
return BACK_REFERENCE;
|
||||
}
|
||||
}, mock(NamedParameterJdbcOperations.class), __ -> {});
|
||||
});
|
||||
|
||||
DataAccessStrategy dataAccessStrategy = mock(DataAccessStrategy.class);
|
||||
DefaultJdbcInterpreter interpreter = new DefaultJdbcInterpreter(context, dataAccessStrategy);
|
||||
|
||||
@@ -17,6 +17,7 @@ package org.springframework.data.jdbc.core;
|
||||
|
||||
import static java.util.Arrays.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -44,7 +45,6 @@ import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -175,11 +175,7 @@ public class EntityRowMapperUnitTests {
|
||||
|
||||
private <T> EntityRowMapper<T> createRowMapper(Class<T> type, NamingStrategy namingStrategy) {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext( //
|
||||
namingStrategy, //
|
||||
mock(NamedParameterJdbcOperations.class), //
|
||||
__ -> {} //
|
||||
);
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy);
|
||||
|
||||
DataAccessStrategy accessStrategy = mock(DataAccessStrategy.class);
|
||||
|
||||
@@ -188,13 +184,13 @@ public class EntityRowMapperUnitTests {
|
||||
.findAllByProperty(eq(ID_FOR_ENTITY_NOT_REFERENCING_MAP), any(JdbcPersistentProperty.class));
|
||||
|
||||
doReturn(new HashSet<>(asList( //
|
||||
new SimpleEntry("one", new Trivial()), //
|
||||
new SimpleEntry("two", new Trivial()) //
|
||||
new SimpleEntry<>("one", new Trivial()), //
|
||||
new SimpleEntry<>("two", new Trivial()) //
|
||||
))).when(accessStrategy).findAllByProperty(eq(ID_FOR_ENTITY_REFERENCING_MAP), any(JdbcPersistentProperty.class));
|
||||
|
||||
doReturn(new HashSet<>(asList( //
|
||||
new SimpleEntry(1, new Trivial()), //
|
||||
new SimpleEntry(2, new Trivial()) //
|
||||
new SimpleEntry<>(1, new Trivial()), //
|
||||
new SimpleEntry<>(2, new Trivial()) //
|
||||
))).when(accessStrategy).findAllByProperty(eq(ID_FOR_ENTITY_REFERENCING_LIST), any(JdbcPersistentProperty.class));
|
||||
|
||||
GenericConversionService conversionService = new GenericConversionService();
|
||||
@@ -215,7 +211,7 @@ public class EntityRowMapperUnitTests {
|
||||
"Number of values [%d] must be a multiple of the number of columns [%d]", //
|
||||
values.length, //
|
||||
columns.size() //
|
||||
) //
|
||||
) //
|
||||
);
|
||||
|
||||
List<Map<String, Object>> result = convertValues(columns, values);
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -29,7 +28,6 @@ import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests to verify a contextual {@link NamingStrategy} implementation that customizes using a user-centric
|
||||
@@ -96,11 +94,9 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteByPath(PropertyPath.from("ref.further", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".SecondLevelReferencedEntity " +
|
||||
"WHERE " + user + ".ReferencedEntity IN " +
|
||||
"(SELECT l1id FROM " + user + ".ReferencedEntity " +
|
||||
"WHERE " + user + ".DummyEntity = :rootId)");
|
||||
assertThat(sql)
|
||||
.isEqualTo("DELETE FROM " + user + ".SecondLevelReferencedEntity " + "WHERE " + user + ".ReferencedEntity IN "
|
||||
+ "(SELECT l1id FROM " + user + ".ReferencedEntity " + "WHERE " + user + ".DummyEntity = :rootId)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,8 +122,7 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteAllSql(PropertyPath.from("ref", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".ReferencedEntity WHERE " + user + ".DummyEntity IS NOT NULL");
|
||||
assertThat(sql).isEqualTo("DELETE FROM " + user + ".ReferencedEntity WHERE " + user + ".DummyEntity IS NOT NULL");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -140,11 +135,9 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.createDeleteAllSql(PropertyPath.from("ref.further", DummyEntity.class));
|
||||
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM " + user + ".SecondLevelReferencedEntity " +
|
||||
"WHERE " + user + ".ReferencedEntity IN " +
|
||||
"(SELECT l1id FROM " + user + ".ReferencedEntity " +
|
||||
"WHERE " + user + ".DummyEntity IS NOT NULL)");
|
||||
assertThat(sql)
|
||||
.isEqualTo("DELETE FROM " + user + ".SecondLevelReferencedEntity " + "WHERE " + user + ".ReferencedEntity IN "
|
||||
+ "(SELECT l1id FROM " + user + ".ReferencedEntity " + "WHERE " + user + ".DummyEntity IS NOT NULL)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -166,8 +159,8 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inside a {@link Runnable}, fetch the {@link ThreadLocal}-based username and execute the provided
|
||||
* set of assertions. Then signal through the provided {@link CountDownLatch}.
|
||||
* Inside a {@link Runnable}, fetch the {@link ThreadLocal}-based username and execute the provided set of assertions.
|
||||
* Then signal through the provided {@link CountDownLatch}.
|
||||
*/
|
||||
private void threadedTest(String user, CountDownLatch latch, Consumer<String> testAssertions) {
|
||||
|
||||
@@ -185,7 +178,7 @@ public class SqlGeneratorContextBasedNamingStrategyUnitTests {
|
||||
*/
|
||||
private SqlGenerator configureSqlGenerator(NamingStrategy namingStrategy) {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy, mock(NamedParameterJdbcOperations.class), __ -> {});
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy);
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
|
||||
|
||||
return new SqlGenerator(context, persistentEntity, new SqlGeneratorSource(context));
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.junit.Test;
|
||||
@@ -26,7 +25,6 @@ import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests the {@link SqlGenerator} with a fixed {@link NamingStrategy} implementation containing a hard wired
|
||||
@@ -170,10 +168,10 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
|
||||
|
||||
String sql = sqlGenerator.getDeleteByList();
|
||||
|
||||
assertThat(sql).isEqualTo("DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_DummyEntity WHERE FixedCustomPropertyPrefix_id IN (:ids)");
|
||||
assertThat(sql).isEqualTo(
|
||||
"DELETE FROM FixedCustomSchema.FixedCustomTablePrefix_DummyEntity WHERE FixedCustomPropertyPrefix_id IN (:ids)");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Plug in a custom {@link NamingStrategy} for this test case.
|
||||
*
|
||||
@@ -181,7 +179,7 @@ public class SqlGeneratorFixedNamingStrategyUnitTests {
|
||||
*/
|
||||
private SqlGenerator configureSqlGenerator(NamingStrategy namingStrategy) {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy, mock(NamedParameterJdbcOperations.class), __ -> {});
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy);
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
|
||||
return new SqlGenerator(context, persistentEntity, new SqlGeneratorSource(context));
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -30,7 +29,6 @@ import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentProperty;
|
||||
import org.springframework.data.jdbc.mapping.model.NamingStrategy;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link SqlGenerator}.
|
||||
@@ -46,7 +44,7 @@ public class SqlGeneratorUnitTests {
|
||||
public void setUp() {
|
||||
|
||||
NamingStrategy namingStrategy = new PrefixingNamingStrategy();
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy, mock(NamedParameterJdbcOperations.class), __ -> {});
|
||||
JdbcMappingContext context = new JdbcMappingContext(namingStrategy);
|
||||
JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
|
||||
this.sqlGenerator = new SqlGenerator(context, persistentEntity, new SqlGeneratorSource(context));
|
||||
}
|
||||
@@ -135,7 +133,7 @@ public class SqlGeneratorUnitTests {
|
||||
+ "WHERE back-ref = :back-ref");
|
||||
}
|
||||
|
||||
@Test (expected = IllegalArgumentException.class) // DATAJDBC-130
|
||||
@Test(expected = IllegalArgumentException.class) // DATAJDBC-130
|
||||
public void findAllByPropertyOrderedWithoutKey() {
|
||||
String sql = sqlGenerator.getFindAllByProperty("back-ref", null, true);
|
||||
}
|
||||
@@ -150,9 +148,7 @@ public class SqlGeneratorUnitTests {
|
||||
+ "ref.x_l1id AS ref_x_l1id, ref.x_content AS ref_x_content, ref.x_further AS ref_x_further, "
|
||||
+ "DummyEntity.key-column AS key-column "
|
||||
+ "FROM DummyEntity LEFT OUTER JOIN ReferencedEntity AS ref ON ref.DummyEntity = DummyEntity.x_id "
|
||||
+ "WHERE back-ref = :back-ref "
|
||||
+ "ORDER BY key-column"
|
||||
);
|
||||
+ "WHERE back-ref = :back-ref " + "ORDER BY key-column");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.core.conversion;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
@@ -28,7 +26,6 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.core.conversion.AggregateChange.Kind;
|
||||
import org.springframework.data.jdbc.core.conversion.DbAction.Delete;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link JdbcEntityDeleteWriter}
|
||||
@@ -38,14 +35,14 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class JdbcEntityDeleteWriterUnitTests {
|
||||
|
||||
JdbcEntityDeleteWriter converter = new JdbcEntityDeleteWriter(new JdbcMappingContext(mock(NamedParameterJdbcOperations.class)));
|
||||
JdbcEntityDeleteWriter converter = new JdbcEntityDeleteWriter(new JdbcMappingContext());
|
||||
|
||||
@Test
|
||||
public void deleteDeletesTheEntityAndReferencedEntities() {
|
||||
|
||||
SomeEntity entity = new SomeEntity(23L);
|
||||
|
||||
AggregateChange<SomeEntity> aggregateChange = new AggregateChange(Kind.DELETE, SomeEntity.class, entity);
|
||||
AggregateChange<SomeEntity> aggregateChange = new AggregateChange<>(Kind.DELETE, SomeEntity.class, entity);
|
||||
|
||||
converter.write(entity, aggregateChange);
|
||||
|
||||
@@ -54,7 +51,7 @@ public class JdbcEntityDeleteWriterUnitTests {
|
||||
Tuple.tuple(Delete.class, YetAnother.class), //
|
||||
Tuple.tuple(Delete.class, OtherEntity.class), //
|
||||
Tuple.tuple(Delete.class, SomeEntity.class) //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.core.conversion;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@@ -36,7 +35,6 @@ import org.springframework.data.jdbc.core.conversion.DbAction.Delete;
|
||||
import org.springframework.data.jdbc.core.conversion.DbAction.Insert;
|
||||
import org.springframework.data.jdbc.core.conversion.DbAction.Update;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link JdbcEntityWriter}
|
||||
@@ -47,7 +45,7 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
public class JdbcEntityWriterUnitTests {
|
||||
|
||||
public static final long SOME_ENTITY_ID = 23L;
|
||||
JdbcEntityWriter converter = new JdbcEntityWriter(new JdbcMappingContext(mock(NamedParameterJdbcOperations.class)));
|
||||
JdbcEntityWriter converter = new JdbcEntityWriter(new JdbcMappingContext());
|
||||
|
||||
@Test // DATAJDBC-112
|
||||
public void newEntityGetsConvertedToOneInsert() {
|
||||
@@ -62,7 +60,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
.extracting(DbAction::getClass, DbAction::getEntityType, this::extractPath) //
|
||||
.containsExactly( //
|
||||
tuple(Insert.class, SingleReferenceEntity.class, "") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-112
|
||||
@@ -79,7 +77,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
.containsExactly( //
|
||||
tuple(Delete.class, Element.class, "other"), //
|
||||
tuple(Update.class, SingleReferenceEntity.class, "") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-112
|
||||
@@ -99,7 +97,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Delete.class, Element.class, "other"), //
|
||||
tuple(Update.class, SingleReferenceEntity.class, ""), //
|
||||
tuple(Insert.class, Element.class, "other") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-113
|
||||
@@ -131,7 +129,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Insert.class, SetContainer.class, ""), //
|
||||
tuple(Insert.class, Element.class, "elements"), //
|
||||
tuple(Insert.class, Element.class, "elements") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-113
|
||||
@@ -162,7 +160,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Insert.class, CascadingReferenceMiddleElement.class, "other"), //
|
||||
tuple(Insert.class, Element.class, "other.element"), //
|
||||
tuple(Insert.class, Element.class, "other.element") //
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-131
|
||||
@@ -195,12 +193,12 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Insert.class, Element.class, "one", "elements"), //
|
||||
tuple(Insert.class, Element.class, "two", "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, MapContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, "two", "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, MapContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, "one", "elements") //
|
||||
);
|
||||
tuple(Insert.class, MapContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, "two", "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, MapContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, "one", "elements") //
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-183
|
||||
@@ -259,8 +257,8 @@ public class JdbcEntityWriterUnitTests {
|
||||
public void newEntityWithListResultsInAdditionalInsertPerElement() {
|
||||
|
||||
ListContainer entity = new ListContainer(null);
|
||||
entity.elements.add( new Element(null));
|
||||
entity.elements.add( new Element(null));
|
||||
entity.elements.add(new Element(null));
|
||||
entity.elements.add(new Element(null));
|
||||
|
||||
AggregateChange<ListContainer> aggregateChange = new AggregateChange(Kind.SAVE, ListContainer.class, entity);
|
||||
converter.write(entity, aggregateChange);
|
||||
@@ -272,12 +270,12 @@ public class JdbcEntityWriterUnitTests {
|
||||
tuple(Insert.class, Element.class, 0, "elements"), //
|
||||
tuple(Insert.class, Element.class, 1, "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, ListContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, 1, "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, ListContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, 0, "elements") //
|
||||
);
|
||||
tuple(Insert.class, ListContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, 1, "elements") //
|
||||
).containsSubsequence( // container comes before the elements
|
||||
tuple(Insert.class, ListContainer.class, null, ""), //
|
||||
tuple(Insert.class, Element.class, 0, "elements") //
|
||||
);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-131
|
||||
@@ -303,7 +301,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
public void listTriggersDeletePlusInsert() {
|
||||
|
||||
ListContainer entity = new ListContainer(SOME_ENTITY_ID);
|
||||
entity.elements.add( new Element(null));
|
||||
entity.elements.add(new Element(null));
|
||||
|
||||
AggregateChange<ListContainer> aggregateChange = new AggregateChange(Kind.SAVE, ListContainer.class, entity);
|
||||
|
||||
@@ -379,7 +377,7 @@ public class JdbcEntityWriterUnitTests {
|
||||
private static class ListContainer {
|
||||
|
||||
@Id final Long id;
|
||||
List< Element> elements = new ArrayList<>();
|
||||
List<Element> elements = new ArrayList<>();
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
|
||||
@@ -16,23 +16,21 @@
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.domain.Persistable;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BasicJdbcPersistentEntityInformation}.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class BasicJdbcPersistentEntityInformationUnitTests {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext( //
|
||||
NamingStrategy.INSTANCE, //
|
||||
mock(NamedParameterJdbcOperations.class), //
|
||||
cs -> {});
|
||||
JdbcMappingContext context = new JdbcMappingContext();
|
||||
private DummyEntity dummyEntity = new DummyEntity();
|
||||
private PersistableDummyEntity persistableDummyEntity = new PersistableDummyEntity();
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@@ -26,16 +25,16 @@ import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link BasicJdbcPersistentProperty}.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class BasicJdbcPersistentPropertyUnitTests {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext(mock(NamedParameterJdbcOperations.class));
|
||||
JdbcMappingContext context = new JdbcMappingContext();
|
||||
|
||||
@Test // DATAJDBC-104
|
||||
public void enumGetsStoredAsString() {
|
||||
|
||||
@@ -15,42 +15,38 @@
|
||||
*/
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link DelimiterNamingStrategy}.
|
||||
*
|
||||
* @author Kazuki Shimizu
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class DelimiterNamingStrategyUnitTests {
|
||||
|
||||
private final DelimiterNamingStrategy target = new DelimiterNamingStrategy();
|
||||
DelimiterNamingStrategy target = new DelimiterNamingStrategy();
|
||||
|
||||
private final JdbcPersistentEntity<?> persistentEntity =
|
||||
new JdbcMappingContext(target, mock(NamedParameterJdbcOperations.class), mock(ConversionCustomizer.class))
|
||||
.getRequiredPersistentEntity(DummyEntity.class);
|
||||
JdbcPersistentEntity<?> persistentEntity = new JdbcMappingContext(target)
|
||||
.getRequiredPersistentEntity(DummyEntity.class);
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getTableName() {
|
||||
assertThat(target.getTableName(persistentEntity.getType()))
|
||||
.isEqualTo("dummy_entity");
|
||||
assertThat(target.getTableName(persistentEntity.getType())).isEqualTo("dummy_entity");
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getColumnName() {
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("id")))
|
||||
.isEqualTo("id");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("createdAt")))
|
||||
.isEqualTo("created_at");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("id"))).isEqualTo("id");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("createdAt"))).isEqualTo("created_at");
|
||||
assertThat(target.getColumnName(persistentEntity.getPersistentProperty("dummySubEntities")))
|
||||
.isEqualTo("dummy_sub_entities");
|
||||
}
|
||||
@@ -69,28 +65,24 @@ public class DelimiterNamingStrategyUnitTests {
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getSchema() {
|
||||
assertThat(target.getSchema())
|
||||
.isEmpty();
|
||||
assertThat(target.getSchema()).isEmpty();
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-184
|
||||
public void getQualifiedTableName() {
|
||||
assertThat(target.getQualifiedTableName(persistentEntity.getType()))
|
||||
.isEqualTo("dummy_entity");
|
||||
assertThat(target.getQualifiedTableName(persistentEntity.getType())).isEqualTo("dummy_entity");
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class DummyEntity {
|
||||
@Id
|
||||
private int id;
|
||||
@Id private int id;
|
||||
private LocalDateTime createdAt;
|
||||
private List<DummySubEntity> dummySubEntities;
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class DummySubEntity {
|
||||
@Id
|
||||
private int id;
|
||||
@Id private int id;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,55 +16,42 @@
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.mapping.PropertyPath;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link JdbcMappingContext}.
|
||||
*
|
||||
* @author Jens Schauder
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
public class JdbcMappingContextUnitTests {
|
||||
|
||||
NamingStrategy namingStrategy = NamingStrategy.INSTANCE;
|
||||
NamedParameterJdbcOperations jdbcTemplate = mock(NamedParameterJdbcOperations.class);
|
||||
ConversionCustomizer customizer = mock(ConversionCustomizer.class);
|
||||
|
||||
@Test // DATAJDBC-142
|
||||
public void referencedEntitiesGetFound() {
|
||||
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy, jdbcTemplate, customizer);
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext();
|
||||
|
||||
List<PropertyPath> propertyPaths = mappingContext.referencedEntities(DummyEntity.class, null);
|
||||
|
||||
assertThat(propertyPaths) //
|
||||
.extracting(PropertyPath::toDotPath) //
|
||||
.containsExactly( //
|
||||
"one.two", //
|
||||
"one" //
|
||||
);
|
||||
.containsExactly("one.two", "one");
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-142
|
||||
public void propertyPathDoesNotDependOnNamingStrategy() {
|
||||
|
||||
namingStrategy = mock(NamingStrategy.class);
|
||||
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy, jdbcTemplate, customizer);
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext();
|
||||
|
||||
List<PropertyPath> propertyPaths = mappingContext.referencedEntities(DummyEntity.class, null);
|
||||
|
||||
assertThat(propertyPaths) //
|
||||
.extracting(PropertyPath::toDotPath) //
|
||||
.containsExactly( //
|
||||
"one.two", //
|
||||
"one" //
|
||||
);
|
||||
.containsExactly("one.two", "one");
|
||||
}
|
||||
|
||||
static class DummyEntity {
|
||||
|
||||
@@ -16,10 +16,8 @@
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link JdbcPersistentEntityImpl}.
|
||||
@@ -29,7 +27,7 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
*/
|
||||
public class JdbcPersistentEntityImplUnitTests {
|
||||
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext(mock(NamedParameterJdbcOperations.class));
|
||||
JdbcMappingContext mappingContext = new JdbcMappingContext();
|
||||
|
||||
@Test // DATAJDBC-106
|
||||
public void discoversAnnotatedTableName() {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
package org.springframework.data.jdbc.mapping.model;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
@@ -24,7 +23,6 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcPersistentEntityImplUnitTests.DummySubEntity;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
|
||||
/**
|
||||
* Unit tests for the {@link NamingStrategy}.
|
||||
@@ -35,8 +33,7 @@ import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
public class NamingStrategyUnitTests {
|
||||
|
||||
private final NamingStrategy target = NamingStrategy.INSTANCE;
|
||||
private final JdbcMappingContext context = new JdbcMappingContext(target, mock(NamedParameterJdbcOperations.class),
|
||||
mock(ConversionCustomizer.class));
|
||||
private final JdbcMappingContext context = new JdbcMappingContext(target);
|
||||
private final JdbcPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
|
||||
|
||||
@Test
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -85,8 +86,9 @@ public class MyBatisHsqlIntegrationTests {
|
||||
}
|
||||
|
||||
@Bean
|
||||
DataAccessStrategy dataAccessStrategy(JdbcMappingContext context, SqlSession sqlSession) {
|
||||
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, sqlSession);
|
||||
DataAccessStrategy dataAccessStrategy(JdbcMappingContext context, SqlSession sqlSession, EmbeddedDatabase db) {
|
||||
return MyBatisDataAccessStrategy.createCombinedAccessStrategy(context, new NamedParameterJdbcTemplate(db),
|
||||
sqlSession);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import lombok.Data;
|
||||
import lombok.Value;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
@@ -140,10 +138,5 @@ public class JdbcRepositoryIdGenerationIntegrationTests {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Bean
|
||||
NamedParameterJdbcTemplate template(DataSource db) {
|
||||
return new NamedParameterJdbcTemplate(db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,19 +67,16 @@ public class SimpleJdbcRepositoryEventsUnitTests {
|
||||
@Before
|
||||
public void before() {
|
||||
|
||||
JdbcMappingContext context = new JdbcMappingContext(createIdGeneratingOperations());
|
||||
JdbcMappingContext context = new JdbcMappingContext();
|
||||
|
||||
dataAccessStrategy = spy(new DefaultDataAccessStrategy( //
|
||||
new SqlGeneratorSource(context), //
|
||||
context //
|
||||
));
|
||||
NamedParameterJdbcOperations operations = createIdGeneratingOperations();
|
||||
SqlGeneratorSource generatorSource = new SqlGeneratorSource(context);
|
||||
|
||||
JdbcRepositoryFactory factory = new JdbcRepositoryFactory( //
|
||||
dataAccessStrategy, //
|
||||
context, //
|
||||
publisher);
|
||||
this.dataAccessStrategy = spy(new DefaultDataAccessStrategy(generatorSource, context, operations));
|
||||
|
||||
repository = factory.getRepository(DummyEntityRepository.class);
|
||||
JdbcRepositoryFactory factory = new JdbcRepositoryFactory(dataAccessStrategy, context, publisher, operations);
|
||||
|
||||
this.repository = factory.getRepository(DummyEntityRepository.class);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-99
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.springframework.data.repository.core.NamedQueries;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.RepositoryQuery;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
|
||||
/**
|
||||
@@ -48,6 +49,7 @@ public class JdbcQueryLookupStrategyUnitTests {
|
||||
ProjectionFactory projectionFactory = mock(ProjectionFactory.class);
|
||||
RepositoryMetadata metadata;
|
||||
NamedQueries namedQueries = mock(NamedQueries.class);
|
||||
NamedParameterJdbcOperations operations = mock(NamedParameterJdbcOperations.class);
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
@@ -69,14 +71,13 @@ public class JdbcQueryLookupStrategyUnitTests {
|
||||
|
||||
repositoryQuery.execute(new Object[] {});
|
||||
|
||||
verify(mappingContext.getTemplate()).queryForObject(anyString(), any(SqlParameterSource.class),
|
||||
eq(numberFormatMapper));
|
||||
verify(operations).queryForObject(anyString(), any(SqlParameterSource.class), eq(numberFormatMapper));
|
||||
}
|
||||
|
||||
private RepositoryQuery getRepositoryQuery(String name, RowMapperMap rowMapperMap) {
|
||||
|
||||
JdbcQueryLookupStrategy queryLookupStrategy = new JdbcQueryLookupStrategy(mappingContext, accessStrategy,
|
||||
rowMapperMap);
|
||||
rowMapperMap, operations);
|
||||
|
||||
return queryLookupStrategy.resolveQuery(getMethod(name), metadata, projectionFactory, namedQueries);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import org.springframework.data.jdbc.core.DefaultDataAccessStrategy;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.repository.RowMapperMap;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,7 @@ public class JdbcRepositoryFactoryBeanUnitTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
this.mappingContext = new JdbcMappingContext(mock(NamedParameterJdbcOperations.class));
|
||||
this.mappingContext = new JdbcMappingContext();
|
||||
|
||||
// Setup standard configuration
|
||||
factoryBean = new JdbcRepositoryFactoryBean<>(DummyEntityRepository.class);
|
||||
|
||||
@@ -23,10 +23,10 @@ import java.sql.ResultSet;
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.jdbc.mapping.model.JdbcMappingContext;
|
||||
import org.springframework.data.repository.query.DefaultParameters;
|
||||
import org.springframework.data.repository.query.Parameters;
|
||||
import org.springframework.jdbc.core.RowMapper;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
|
||||
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
|
||||
/**
|
||||
@@ -38,9 +38,10 @@ import org.springframework.jdbc.core.namedparam.SqlParameterSource;
|
||||
public class JdbcRepositoryQueryUnitTests {
|
||||
|
||||
JdbcQueryMethod queryMethod;
|
||||
JdbcMappingContext context;
|
||||
|
||||
RowMapper<?> defaultRowMapper;
|
||||
JdbcRepositoryQuery query;
|
||||
NamedParameterJdbcOperations operations;
|
||||
|
||||
@Before
|
||||
public void setup() throws NoSuchMethodException {
|
||||
@@ -51,10 +52,10 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
JdbcRepositoryQueryUnitTests.class.getDeclaredMethod("dummyMethod"));
|
||||
doReturn(parameters).when(queryMethod).getParameters();
|
||||
|
||||
this.context = mock(JdbcMappingContext.class, RETURNS_DEEP_STUBS);
|
||||
this.defaultRowMapper = mock(RowMapper.class);
|
||||
this.operations = mock(NamedParameterJdbcOperations.class);
|
||||
|
||||
this.query = new JdbcRepositoryQuery(queryMethod, context, defaultRowMapper);
|
||||
this.query = new JdbcRepositoryQuery(queryMethod, operations, defaultRowMapper);
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-165
|
||||
@@ -74,7 +75,7 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
|
||||
query.execute(new Object[] {});
|
||||
|
||||
verify(context.getTemplate()).queryForObject(anyString(), any(SqlParameterSource.class), eq(defaultRowMapper));
|
||||
verify(operations).queryForObject(anyString(), any(SqlParameterSource.class), eq(defaultRowMapper));
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-165
|
||||
@@ -84,7 +85,7 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
|
||||
query.execute(new Object[] {});
|
||||
|
||||
verify(context.getTemplate()).queryForObject(anyString(), any(SqlParameterSource.class), eq(defaultRowMapper));
|
||||
verify(operations).queryForObject(anyString(), any(SqlParameterSource.class), eq(defaultRowMapper));
|
||||
}
|
||||
|
||||
@Test // DATAJDBC-165
|
||||
@@ -93,9 +94,9 @@ public class JdbcRepositoryQueryUnitTests {
|
||||
doReturn("some sql statement").when(queryMethod).getAnnotatedQuery();
|
||||
doReturn(CustomRowMapper.class).when(queryMethod).getRowMapperClass();
|
||||
|
||||
new JdbcRepositoryQuery(queryMethod, context, defaultRowMapper).execute(new Object[] {});
|
||||
new JdbcRepositoryQuery(queryMethod, operations, defaultRowMapper).execute(new Object[] {});
|
||||
|
||||
verify(context.getTemplate()) //
|
||||
verify(operations) //
|
||||
.queryForObject(anyString(), any(SqlParameterSource.class), isA(CustomRowMapper.class));
|
||||
}
|
||||
|
||||
|
||||
@@ -54,14 +54,9 @@ public class TestConfiguration {
|
||||
@Bean
|
||||
JdbcRepositoryFactory jdbcRepositoryFactory(DataAccessStrategy dataAccessStrategy) {
|
||||
|
||||
NamedParameterJdbcOperations jdbcTemplate = namedParameterJdbcTemplate();
|
||||
JdbcMappingContext context = new JdbcMappingContext(NamingStrategy.INSTANCE);
|
||||
|
||||
final JdbcMappingContext context = new JdbcMappingContext(NamingStrategy.INSTANCE, jdbcTemplate, __ -> {});
|
||||
|
||||
return new JdbcRepositoryFactory( //
|
||||
dataAccessStrategy, //
|
||||
context, //
|
||||
publisher);
|
||||
return new JdbcRepositoryFactory(dataAccessStrategy, context, publisher, namedParameterJdbcTemplate());
|
||||
}
|
||||
|
||||
@Bean
|
||||
@@ -76,17 +71,14 @@ public class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
DataAccessStrategy defaultDataAccessStrategy(JdbcMappingContext context) {
|
||||
return new DefaultDataAccessStrategy(new SqlGeneratorSource(context), context);
|
||||
return new DefaultDataAccessStrategy(new SqlGeneratorSource(context), context, namedParameterJdbcTemplate());
|
||||
}
|
||||
|
||||
@Bean
|
||||
JdbcMappingContext jdbcMappingContext(NamedParameterJdbcOperations template, Optional<NamingStrategy> namingStrategy,
|
||||
Optional<ConversionCustomizer> conversionCustomizer) {
|
||||
|
||||
return new JdbcMappingContext( //
|
||||
namingStrategy.orElse(NamingStrategy.INSTANCE), //
|
||||
template, //
|
||||
conversionCustomizer.orElse(conversionService -> {}) //
|
||||
);
|
||||
return new JdbcMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE),
|
||||
conversionCustomizer.orElse(conversionService -> {}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user