Class AbstractJdbcConfiguration
java.lang.Object
org.springframework.data.jdbc.repository.config.AbstractJdbcConfiguration
- All Implemented Interfaces:
Aware
,ApplicationContextAware
- Direct Known Subclasses:
MyBatisJdbcConfiguration
@Configuration(proxyBeanMethods=false)
public class AbstractJdbcConfiguration
extends Object
implements ApplicationContextAware
Beans that must be registered for Spring Data JDBC to work.
- Since:
- 1.1
- Author:
- Greg Turnquist, Jens Schauder, Mark Paluch, Michael Simons, Christoph Strobl, Myeonghyeon Lee, Chirag Tailor
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondataAccessStrategyBean
(NamedParameterJdbcOperations operations, JdbcConverter jdbcConverter, JdbcMappingContext context, Dialect dialect) jdbcAggregateTemplate
(ApplicationContext applicationContext, JdbcMappingContext mappingContext, JdbcConverter converter, DataAccessStrategy dataAccessStrategy) Register aJdbcAggregateTemplate
as a bean for easy use in applications that need a lower level of abstraction than the normal repository abstraction.jdbcConverter
(JdbcMappingContext mappingContext, NamedParameterJdbcOperations operations, RelationResolver relationResolver, JdbcCustomConversions conversions, Dialect dialect) Creates aRelationalConverter
using the configuredjdbcMappingContext(Optional, JdbcCustomConversions)
.Register customConverter
s in aJdbcCustomConversions
object if required.jdbcDialect
(NamedParameterJdbcOperations operations) Resolves aJDBC dialect
by inspectingNamedParameterJdbcOperations
.jdbcMappingContext
(Optional<NamingStrategy> namingStrategy, JdbcCustomConversions customConversions) Register aJdbcMappingContext
and apply an optionalNamingStrategy
.void
setApplicationContext
(ApplicationContext applicationContext) protected List<?>
-
Constructor Details
-
AbstractJdbcConfiguration
public AbstractJdbcConfiguration()
-
-
Method Details
-
jdbcMappingContext
@Bean public JdbcMappingContext jdbcMappingContext(Optional<NamingStrategy> namingStrategy, JdbcCustomConversions customConversions) Register aJdbcMappingContext
and apply an optionalNamingStrategy
.- Parameters:
namingStrategy
- optionalNamingStrategy
. UseNamingStrategy.INSTANCE
as fallback.customConversions
- seejdbcCustomConversions()
.- Returns:
- must not be null.
-
jdbcConverter
@Bean public JdbcConverter jdbcConverter(JdbcMappingContext mappingContext, NamedParameterJdbcOperations operations, @Lazy RelationResolver relationResolver, JdbcCustomConversions conversions, Dialect dialect) Creates aRelationalConverter
using the configuredjdbcMappingContext(Optional, JdbcCustomConversions)
. Will getjdbcCustomConversions()
()} applied.- Returns:
- must not be null.
- See Also:
-
jdbcCustomConversions
Register customConverter
s in aJdbcCustomConversions
object if required. TheseJdbcCustomConversions
will be registered with thejdbcConverter(JdbcMappingContext, NamedParameterJdbcOperations, RelationResolver, JdbcCustomConversions, Dialect)
. Returns an emptyJdbcCustomConversions
instance by default.- Returns:
- will never be null.
-
userConverters
-
jdbcAggregateTemplate
@Bean public JdbcAggregateTemplate jdbcAggregateTemplate(ApplicationContext applicationContext, JdbcMappingContext mappingContext, JdbcConverter converter, DataAccessStrategy dataAccessStrategy) Register aJdbcAggregateTemplate
as a bean for easy use in applications that need a lower level of abstraction than the normal repository abstraction.- Parameters:
applicationContext
- for publishing events. Must not be null.mappingContext
- the mapping context to be used. Must not be null.converter
- the conversions used when reading and writing from/to the database. Must not be null.- Returns:
- a
JdbcAggregateTemplate
. Will never be null.
-
dataAccessStrategyBean
@Bean public DataAccessStrategy dataAccessStrategyBean(NamedParameterJdbcOperations operations, JdbcConverter jdbcConverter, JdbcMappingContext context, Dialect dialect) Create aDataAccessStrategy
for reuse in theJdbcAggregateOperations
and theJdbcConverter
. Override this method to register a bean of typeDataAccessStrategy
if your use case requires a more specializedDataAccessStrategy
.- Returns:
- will never be null.
-
jdbcDialect
Resolves aJDBC dialect
by inspectingNamedParameterJdbcOperations
.- Parameters:
operations
- theNamedParameterJdbcOperations
allowing access to aConnection
.- Returns:
- the
Dialect
to be used. - Throws:
DialectResolver.NoDialectException
- if theDialect
cannot be determined.- Since:
- 2.0
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-