diff --git a/jpa/boot-read-replica-postgresql/docker-compose.yaml b/jpa/boot-read-replica-postgresql/docker-compose.yaml
index 3f77dcb03..3e7644958 100644
--- a/jpa/boot-read-replica-postgresql/docker-compose.yaml
+++ b/jpa/boot-read-replica-postgresql/docker-compose.yaml
@@ -1,5 +1,3 @@
-version: '2'
-
services:
postgresql-master:
image: 'bitnami/postgresql:latest'
diff --git a/jpa/boot-read-replica-postgresql/pom.xml b/jpa/boot-read-replica-postgresql/pom.xml
index 6b8ae2b23..4e8019971 100644
--- a/jpa/boot-read-replica-postgresql/pom.xml
+++ b/jpa/boot-read-replica-postgresql/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 3.3.5
+ 3.4.0-RC1
com.example.demo
@@ -109,7 +109,7 @@
- 1.22.0
+ 1.24.0
diff --git a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/DatabaseConfig.java b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/DatabaseConfig.java
index 038437b99..862496cc2 100644
--- a/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/DatabaseConfig.java
+++ b/jpa/boot-read-replica-postgresql/src/main/java/com/example/demo/readreplica/config/DatabaseConfig.java
@@ -22,7 +22,7 @@ DataSourceProperties primaryDataSourceProperties() {
}
@Bean
- @ConfigurationProperties(PRIMARY_DATABASE_PROPERTY_KEY_PREFIX + ".configuration")
+ @ConfigurationProperties(PRIMARY_DATABASE_PROPERTY_KEY_PREFIX + ".hikari")
DataSource primaryDataSource(final DataSourceProperties primaryDataSourceProperties) {
return primaryDataSourceProperties
.initializeDataSourceBuilder()
diff --git a/jpa/boot-read-replica-postgresql/src/main/resources/application.yml b/jpa/boot-read-replica-postgresql/src/main/resources/application.yml
index cc10ed9d7..90cbe6ec0 100644
--- a/jpa/boot-read-replica-postgresql/src/main/resources/application.yml
+++ b/jpa/boot-read-replica-postgresql/src/main/resources/application.yml
@@ -6,9 +6,11 @@ spring:
username: postgres_write
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://localhost:5432/my_database
- configuration:
+ hikari:
auto-commit: false
- poolName: primaryHikariPool
+ pool-name: primaryHikariPool
+ data-source-properties:
+ ApplicationName: ${spring.application.name}
replica:
datasource:
password: repl_password
@@ -18,11 +20,31 @@ spring:
hikari:
auto-commit: false
poolName: replicaHikariPool
-
+################ Database #####################
+ data:
+ jpa:
+ repositories:
+ bootstrap-mode: deferred
jpa:
open-in-view: false
+ show-sql: false
hibernate:
ddl-auto: validate
+ properties:
+ hibernate:
+ connection:
+ provider_disables_autocommit: true
+ jdbc:
+ time_zone: UTC
+ batch_size: 25
+ lob.non_contextual_creation : true
+ generate_statistics: false
+ order_inserts: true
+ order_updates: true
+ query:
+ fail_on_pagination_over_collection_fetch: true
+ in_clause_parameter_padding: true
+ plan_cache_max_size: 4096
threads:
virtual:
enabled: true
@@ -30,14 +52,14 @@ spring:
# spring boot log level property
logging:
level:
- read-replica-logger : DEBUG
+ read-replica-logger: DEBUG
jdbc:
- excludedDataSourceBeanNames: dataSource
datasource-proxy:
+ enabled: true
multiline: false
logging: slf4j
query:
logger-name: read-replica-logger
log-level: DEBUG
enable-logging: true
- enabled: true
\ No newline at end of file
+ excluded-data-source-bean-names: dataSource
\ No newline at end of file
diff --git a/jpa/boot-read-replica-postgresql/src/test/java/com/example/demo/readreplica/ReadReplicaApplicationTests.java b/jpa/boot-read-replica-postgresql/src/test/java/com/example/demo/readreplica/ReadReplicaApplicationTests.java
index 4f9676f1a..cf44554e1 100644
--- a/jpa/boot-read-replica-postgresql/src/test/java/com/example/demo/readreplica/ReadReplicaApplicationTests.java
+++ b/jpa/boot-read-replica-postgresql/src/test/java/com/example/demo/readreplica/ReadReplicaApplicationTests.java
@@ -19,8 +19,10 @@
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.LazyConnectionDataSourceProxy;
+import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.util.ReflectionTestUtils;
+@ActiveProfiles("test")
@SpringBootTest
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
diff --git a/jpa/boot-read-replica-postgresql/src/test/resources/application-test.properties b/jpa/boot-read-replica-postgresql/src/test/resources/application-test.properties
new file mode 100644
index 000000000..36c42a367
--- /dev/null
+++ b/jpa/boot-read-replica-postgresql/src/test/resources/application-test.properties
@@ -0,0 +1,2 @@
+#since tests uses only jdbc template, connection optimizations handled by jps is gone, to enabling autocommit
+spring.primary.datasource.hikari.auto-commit=true
\ No newline at end of file