Skip to content

Moved dialect resolution logic into JdbcConfiguration #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package tech.ydb.data.repository.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
import org.springframework.data.jdbc.core.convert.DefaultJdbcTypeFactory;
Expand All @@ -15,9 +17,16 @@

/**
* @author Madiyar Nurgazin
* @author Mikhail Polivakha
*/
@Configuration
@Configuration(proxyBeanMethods = true)
public class AbstractYdbJdbcConfiguration extends AbstractJdbcConfiguration {

@Bean
public YdbDialectProvider ydbDialectProvider() {
return new YdbDialectProvider();
}

@Override
public JdbcConverter jdbcConverter(
JdbcMappingContext mappingContext,
Expand All @@ -32,4 +41,11 @@ public JdbcConverter jdbcConverter(

return new YdbMappingJdbcConverter(mappingContext, relationResolver, conversions, jdbcTypeFactory);
}

@Override
public Dialect jdbcDialect(NamedParameterJdbcOperations operations) {
return ydbDialectProvider()
.getDialect(operations.getJdbcOperations())
.orElseThrow(() -> new IllegalStateException(String.format("Cannot determine a dialect for %s; Please provide a Dialect", operations)));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* @author Madiyar Nurgazin
*/
public class YdbDialectProvider extends DialectResolver.DefaultDialectProvider {

@Override
public Optional<Dialect> getDialect(JdbcOperations operations) {
Optional<Dialect> ydbDialect = Optional.ofNullable(
Expand Down

This file was deleted.