Search in sources :

Example 1 with Primary

use of cn.taketoday.context.annotation.Primary in project today-infrastructure by TAKETODAY.

the class JdbcTemplateConfiguration method jdbcTemplate.

@Bean
@Primary
JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    JdbcProperties.Template template = properties.getTemplate();
    jdbcTemplate.setFetchSize(template.getFetchSize());
    jdbcTemplate.setMaxRows(template.getMaxRows());
    if (template.getQueryTimeout() != null) {
        jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
    }
    return jdbcTemplate;
}
Also used : JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) NamedParameterJdbcTemplate(cn.taketoday.jdbc.core.namedparam.NamedParameterJdbcTemplate) Primary(cn.taketoday.context.annotation.Primary) Bean(cn.taketoday.context.annotation.Bean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean)

Example 2 with Primary

use of cn.taketoday.context.annotation.Primary in project today-framework by TAKETODAY.

the class JdbcTemplateConfiguration method jdbcTemplate.

@Bean
@Primary
JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    JdbcProperties.Template template = properties.getTemplate();
    jdbcTemplate.setFetchSize(template.getFetchSize());
    jdbcTemplate.setMaxRows(template.getMaxRows());
    if (template.getQueryTimeout() != null) {
        jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
    }
    return jdbcTemplate;
}
Also used : JdbcTemplate(cn.taketoday.jdbc.core.JdbcTemplate) NamedParameterJdbcTemplate(cn.taketoday.jdbc.core.namedparam.NamedParameterJdbcTemplate) Primary(cn.taketoday.context.annotation.Primary) Bean(cn.taketoday.context.annotation.Bean) ConditionalOnMissingBean(cn.taketoday.context.condition.ConditionalOnMissingBean)

Aggregations

Bean (cn.taketoday.context.annotation.Bean)2 Primary (cn.taketoday.context.annotation.Primary)2 ConditionalOnMissingBean (cn.taketoday.context.condition.ConditionalOnMissingBean)2 JdbcTemplate (cn.taketoday.jdbc.core.JdbcTemplate)2 NamedParameterJdbcTemplate (cn.taketoday.jdbc.core.namedparam.NamedParameterJdbcTemplate)2