Commit 4b08b71f authored by Matija Obreza's avatar Matija Obreza

Run controlled database migration only when not generating schema automatically

Connect set to readonly(false) by default by JDBC pool
parent c59d4dde
......@@ -89,7 +89,7 @@
<aspectj.version>1.7.2</aspectj.version>
<mysql.version>5.1.31</mysql.version>
<mysql.version>5.1.38</mysql.version>
<hazelcast.version>3.8.1</hazelcast.version>
<oval.version>1.81</oval.version>
......
......@@ -30,7 +30,6 @@ import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.ImportResource;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
......@@ -88,6 +87,7 @@ public class SpringDataBaseConfig {
@Bean
public DataSource dataSource() {
final DataSource dataSource = new DataSource();
dataSource.setDefaultReadOnly(false);
dataSource.setUrl(dbUrl);
dataSource.setDriverClassName(dbDriverClassName);
dataSource.setUsername(dbUsername);
......@@ -103,26 +103,19 @@ public class SpringDataBaseConfig {
return dataSource;
}
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
return new JdbcTemplate(dataSource);
}
private javax.sql.DataSource liquibaseDataSource() {
DriverManagerDataSource dataSource=new DriverManagerDataSource();
dataSource.setDriverClassName(dbDriverClassName);
dataSource.setUrl(dbUrl);
dataSource.setUsername(dbUsername);
dataSource.setPassword(dbPassword);
return dataSource;
}
@Bean(name = "databaseMigration")
public SpringLiquibase databaseMigration() {
SpringLiquibase liquibase = new SpringLiquibase();
// Run controlled database migration only when not generating schema automatically
liquibase.setShouldRun(!dbGenerateDdl);
liquibase.setChangeLog("classpath:liquibase/liquibase-changeLog.yml");
liquibase.setDataSource(liquibaseDataSource());
liquibase.setDataSource(dataSource());
return liquibase;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment