Search in sources :

Example 1 with DefaultQueryMappingConfiguration

use of org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class JdbcQueryLookupStrategyUnitTests method prefersDeclaredQuery.

// GH-1061
@Test
void prefersDeclaredQuery() {
    RowMapper<? extends NumberFormat> numberFormatMapper = mock(RowMapper.class);
    QueryMappingConfiguration mappingConfiguration = new DefaultQueryMappingConfiguration().registerRowMapper(NumberFormat.class, numberFormatMapper);
    RepositoryQuery repositoryQuery = getRepositoryQuery("annotatedQueryWithQueryAndQueryName", mappingConfiguration);
    repositoryQuery.execute(new Object[] {});
    verify(operations).queryForObject(eq("some SQL"), any(SqlParameterSource.class), any(RowMapper.class));
}
Also used : RepositoryQuery(org.springframework.data.repository.query.RepositoryQuery) QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Example 2 with DefaultQueryMappingConfiguration

use of org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration in project spring-data-jdbc by spring-projects.

the class JdbcQueryLookupStrategyUnitTests method typeBasedRowMapperGetsUsedForQuery.

// DATAJDBC-166
@Test
@SuppressWarnings("unchecked")
void typeBasedRowMapperGetsUsedForQuery() {
    RowMapper<? extends NumberFormat> numberFormatMapper = mock(RowMapper.class);
    QueryMappingConfiguration mappingConfiguration = new DefaultQueryMappingConfiguration().registerRowMapper(NumberFormat.class, numberFormatMapper);
    RepositoryQuery repositoryQuery = getRepositoryQuery("returningNumberFormat", mappingConfiguration);
    repositoryQuery.execute(new Object[] {});
    verify(operations).queryForObject(anyString(), any(SqlParameterSource.class), any(RowMapper.class));
}
Also used : RepositoryQuery(org.springframework.data.repository.query.RepositoryQuery) QueryMappingConfiguration(org.springframework.data.jdbc.repository.QueryMappingConfiguration) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) SqlParameterSource(org.springframework.jdbc.core.namedparam.SqlParameterSource) DefaultQueryMappingConfiguration(org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration) RowMapper(org.springframework.jdbc.core.RowMapper) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)2 QueryMappingConfiguration (org.springframework.data.jdbc.repository.QueryMappingConfiguration)2 DefaultQueryMappingConfiguration (org.springframework.data.jdbc.repository.config.DefaultQueryMappingConfiguration)2 RepositoryQuery (org.springframework.data.repository.query.RepositoryQuery)2 RowMapper (org.springframework.jdbc.core.RowMapper)2 SqlParameterSource (org.springframework.jdbc.core.namedparam.SqlParameterSource)2