In the process of setting the dialect, you may also need to set the Converter and MappingContext, if you need database specific JDBC converters.
I inject the application context into a configuration class (using implements ApplicationContextAware storing the context as a static), and then use that to retrieve my database specific Dialog, MappingContext and Converters.
Note: As of spring-data-relational version 3.2, the JdbcOperations, and DataAccessStrategy are passed in if set using @EnableJdbcRepositories, it is the other 3 mentioned above that need to be set using this method.
public class MyRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
extends JdbcRepositoryFactoryBean<T, S, ID> {
public MyRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
super(repositoryInterface);
}
@Override
public void setMappingContext(RelationalMappingContext mappingContext) {
JdbcMappingContext myContext = MyConfig.getBean("myJdbcMappingContext", JdbcMappingContext.class);
super.setMappingContext(myContext);
}
@Override
public void setDialect(Dialect dialect) {
Dialect myJdbcDialect = MyConfig.getBean("myJdbcDialect", Dialect.class);
super.setDialect(myJdbcDialect);
}
@Override
public void setConverter(JdbcConverter converter) {
JdbcConverter myConverter = MyConfig.getBean("myJdbcConverter", JdbcConverter.class);
super.setConverter(myConverter);
}
}