use of org.springframework.data.jdbc.core.mapping.JdbcMappingContext in project spring-data-jdbc by spring-projects.
the class SqlGeneratorContextBasedNamingStrategyUnitTests method configureSqlGenerator.
/**
* Plug in a custom {@link NamingStrategy} for this test case.
*/
private SqlGenerator configureSqlGenerator(NamingStrategy namingStrategy) {
RelationalMappingContext context = new JdbcMappingContext(namingStrategy);
JdbcConverter converter = new BasicJdbcConverter(context, (identifier, path) -> {
throw new UnsupportedOperationException();
});
RelationalPersistentEntity<?> persistentEntity = context.getRequiredPersistentEntity(DummyEntity.class);
return new SqlGenerator(context, converter, persistentEntity, NonQuotingDialect.INSTANCE);
}
use of org.springframework.data.jdbc.core.mapping.JdbcMappingContext in project spring-data-jdbc by spring-projects.
the class AbstractJdbcConfigurationIntegrationTests method registersSimpleTypesFromCustomConversions.
// GH-975
@Test
void registersSimpleTypesFromCustomConversions() {
assertApplicationContext(context -> {
JdbcMappingContext mappingContext = context.getBean(JdbcMappingContext.class);
assertThat(//
mappingContext.getPersistentEntity(AbstractJdbcConfigurationUnderTest.Blah.class)).describedAs(//
"Blah should not be an entity, since there is a WritingConversion configured for it").isNull();
}, AbstractJdbcConfigurationUnderTest.class, Infrastructure.class);
}
use of org.springframework.data.jdbc.core.mapping.JdbcMappingContext in project spring-data-jdbc by spring-projects.
the class JdbcRepositoryFactoryBeanUnitTests method setUp.
@BeforeEach
public void setUp() {
this.mappingContext = new JdbcMappingContext();
// Setup standard configuration
factoryBean = new JdbcRepositoryFactoryBean<>(DummyEntityRepository.class);
when(beanFactory.getBean(NamedParameterJdbcOperations.class)).thenReturn(mock(NamedParameterJdbcOperations.class));
ObjectProvider<DataAccessStrategy> provider = mock(ObjectProvider.class);
when(beanFactory.getBeanProvider(DataAccessStrategy.class)).thenReturn(provider);
when(provider.getIfAvailable(any())).then((Answer<?>) invocation -> ((Supplier<?>) invocation.getArgument(0)).get());
}
use of org.springframework.data.jdbc.core.mapping.JdbcMappingContext in project spring-data-jdbc by spring-projects.
the class SimpleJdbcRepositoryEventsUnitTests method before.
@BeforeEach
public void before() {
RelationalMappingContext context = new JdbcMappingContext();
NamedParameterJdbcOperations operations = createIdGeneratingOperations();
DelegatingDataAccessStrategy delegatingDataAccessStrategy = new DelegatingDataAccessStrategy();
Dialect dialect = HsqlDbDialect.INSTANCE;
JdbcConverter converter = new BasicJdbcConverter(context, delegatingDataAccessStrategy, new JdbcCustomConversions(), new DefaultJdbcTypeFactory(operations.getJdbcOperations()), dialect.getIdentifierProcessing());
SqlGeneratorSource generatorSource = new SqlGeneratorSource(context, converter, dialect);
this.dataAccessStrategy = spy(new DefaultDataAccessStrategy(generatorSource, context, converter, operations));
delegatingDataAccessStrategy.setDelegate(dataAccessStrategy);
doReturn(true).when(dataAccessStrategy).update(any(), any());
JdbcRepositoryFactory factory = new JdbcRepositoryFactory(dataAccessStrategy, context, converter, H2Dialect.INSTANCE, publisher, operations);
this.repository = factory.getRepository(DummyEntityRepository.class);
}
use of org.springframework.data.jdbc.core.mapping.JdbcMappingContext in project spring-data-jdbc by spring-projects.
the class TestConfiguration method jdbcMappingContext.
@Bean
JdbcMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy, CustomConversions conversions) {
JdbcMappingContext mappingContext = new JdbcMappingContext(namingStrategy.orElse(NamingStrategy.INSTANCE));
mappingContext.setSimpleTypeHolder(conversions.getSimpleTypeHolder());
return mappingContext;
}
Aggregations