This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-parent</artifactId> | |
<version>2.2.2.RELEASE</version> | |
<relativePath/> <!-- lookup parent from repository --> | |
</parent> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
spring: | |
datasource-write: | |
driver-class-name: org.postgresql.Driver | |
jdbc-url: jdbc:postgresql://localhost:5432/demo | |
username: 'postgres' | |
password: 'postgres_user_for_db_write' | |
platform: postgresql | |
hikari: | |
idle-timeout: 10000 | |
maximum-pool-size: 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource.configurations; | |
import com.zaxxer.hikari.HikariConfig; | |
import com.zaxxer.hikari.HikariDataSource; | |
import org.hibernate.jpa.HibernatePersistenceProvider; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |
import org.springframework.orm.jpa.JpaTransactionManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource.configurations; | |
import com.zaxxer.hikari.HikariConfig; | |
import com.zaxxer.hikari.HikariDataSource; | |
import org.hibernate.jpa.HibernatePersistenceProvider; | |
import org.springframework.boot.context.properties.ConfigurationProperties; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.data.jpa.repository.config.EnableJpaRepositories; | |
import org.springframework.orm.jpa.JpaTransactionManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource.repository.writeRepository; | |
import com.ehsaniara.multidatasource.model.Customer; | |
import org.springframework.data.repository.CrudRepository; | |
/** | |
* @author Jay Ehsaniara, Dec 30 2019 | |
*/ | |
public interface CustomerWriteRepository extends CrudRepository<Customer, Long> { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource.repository.readRepository; | |
import com.ehsaniara.multidatasource.model.Customer; | |
import org.springframework.data.repository.CrudRepository; | |
/** | |
* @author Jay Ehsaniara, Dec 30 2019 | |
*/ | |
public interface CustomerReadRepository extends CrudRepository<Customer, Long> { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import java.util.Properties; | |
@SpringBootApplication | |
public class DemoApplication { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.ehsaniara.multidatasource.service; | |
import com.ehsaniara.multidatasource.model.Customer; | |
import com.ehsaniara.multidatasource.repository.readRepository.CustomerReadRepository; | |
import com.ehsaniara.multidatasource.repository.writeRepository.CustomerWriteRepository; | |
import org.springframework.stereotype.Service; | |
import org.springframework.util.Assert; | |
import java.util.Optional; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- This file defines pgTAP, a collection of functions for TAP-based unit | |
-- testing. It is distributed under the revised FreeBSD license. | |
-- | |
-- The home page for the pgTAP project is: | |
-- | |
-- http://pgtap.org/ | |
CREATE OR REPLACE FUNCTION pg_version() | |
RETURNS text AS 'SELECT current_setting(''server_version'')' | |
LANGUAGE SQL IMMUTABLE; |