Skip to content

Commit

Permalink
MOSIP-33046: Added in-memory batchDatasource for metadata tables (#1536)
Browse files Browse the repository at this point in the history
Signed-off-by: HimajaDhanyamraju2 <dhanyamraju.himaja2@mindtree.com>
Co-authored-by: HimajaDhanyamraju2 <dhanyamraju.himaja2@mindtree.com>
  • Loading branch information
HimajaDhanyamraju2 and HimajaDhanyamraju2 authored Jul 9, 2024
1 parent 017b01b commit 942d4dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/kernel-salt-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-batch</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@
import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.batch.BatchDataSource;
import org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabase;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
Expand Down Expand Up @@ -111,4 +115,15 @@ public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}

@Bean
@BatchDataSource
public DataSource batchDatasource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
EmbeddedDatabase embeddedDatabase = builder
.setType(EmbeddedDatabaseType.H2)
.generateUniqueName(true)
.build();
return embeddedDatabase;
}

}

0 comments on commit 942d4dd

Please sign in to comment.