<commit_before>package <%= packageName %>.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.codahale.metrics.MetricRegistry;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

/**
 * Database configuration class
 *
 * @author <%= author %>
 * @copyright Maxxton Group <%= currentYear %>
 */
@Configuration
@EnableJpaRepositories("<%= packageName %>.repository")
@EnableTransactionManagement
public class DatabaseConfiguration implements EnvironmentAware
{
  private Environment environment;

  private RelaxedPropertyResolver propertyResolver;

  @Autowired(required = false)
  private MetricRegistry metricRegistry;

  @Override
  public void setEnvironment(Environment environment)
  {
    this.environment = environment;
    this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource.");
  }

  @Bean(name = "dataSource",destroyMethod = "shutdown")
  public DataSource dataSource()
  {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(propertyResolver.getProperty("driverClassName"));
    hikariConfig.setJdbcUrl(propertyResolver.getProperty("url"));
    hikariConfig.setUsername(propertyResolver.getProperty("username"));
    hikariConfig.setPassword(propertyResolver.getProperty("password"));

    hikariConfig.setMaximumPoolSize(5);
    hikariConfig.setPoolName("<%= applicationName %>SpringHikariCP");

    hikariConfig.addDataSourceProperty("dataSource.cachePrepStmts", "true");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSize", "250");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSqlLimit", "2048");
    hikariConfig.addDataSourceProperty("dataSource.useServerPrepStmts", "true");
    hikariConfig.setMetricRegistry(metricRegistry);

    DataSource dataSource = new HikariDataSource(hikariConfig);

    return dataSource;
  }
}
<commit_msg>Changed shutdown method to close, shutdown is deprecated<commit_after>package <%= packageName %>.config;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.bind.RelaxedPropertyResolver;
import org.springframework.core.env.Environment;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.codahale.metrics.MetricRegistry;
import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;

/**
 * Database configuration class
 *
 * @author <%= author %>
 * @copyright Maxxton Group <%= currentYear %>
 */
@Configuration
@EnableJpaRepositories("<%= packageName %>.repository")
@EnableTransactionManagement
public class DatabaseConfiguration implements EnvironmentAware
{
  private Environment environment;

  private RelaxedPropertyResolver propertyResolver;

  @Autowired(required = false)
  private MetricRegistry metricRegistry;

  @Override
  public void setEnvironment(Environment environment)
  {
    this.environment = environment;
    this.propertyResolver = new RelaxedPropertyResolver(environment, "spring.datasource.");
  }

  @Bean(name = "dataSource",destroyMethod = "close")
  public DataSource dataSource()
  {
    HikariConfig hikariConfig = new HikariConfig();
    hikariConfig.setDriverClassName(propertyResolver.getProperty("driverClassName"));
    hikariConfig.setJdbcUrl(propertyResolver.getProperty("url"));
    hikariConfig.setUsername(propertyResolver.getProperty("username"));
    hikariConfig.setPassword(propertyResolver.getProperty("password"));

    hikariConfig.setMaximumPoolSize(5);
    hikariConfig.setPoolName("<%= applicationName %>SpringHikariCP");

    hikariConfig.addDataSourceProperty("dataSource.cachePrepStmts", "true");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSize", "250");
    hikariConfig.addDataSourceProperty("dataSource.prepStmtCacheSqlLimit", "2048");
    hikariConfig.addDataSourceProperty("dataSource.useServerPrepStmts", "true");
    hikariConfig.setMetricRegistry(metricRegistry);

    DataSource dataSource = new HikariDataSource(hikariConfig);

    return dataSource;
  }
}

{'fraction_non_alphanumeric': 0.10258010819808573, 'fraction_numerical': 0.0033291718684977114, 'mean_word_length': 6.854575163398692, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4215543', 'n_tokens_mistral': 1331, 'n_tokens_neox': 1285, 'n_words': 209}