diff --git a/persistence-modules/spring-data-jpa-4/create.sql b/persistence-modules/spring-data-jpa-4/create.sql
new file mode 100644
index 0000000000..1bbe1640a7
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/create.sql
@@ -0,0 +1,2 @@
+create table PERSON (ID int8 not null, FIRST_NAME varchar(255), LAST_NAME varchar(255), primary key (ID))
+create table person (id int8 not null, first_name varchar(255), last_name varchar(255), primary key (id))
diff --git a/persistence-modules/spring-data-jpa-4/pom.xml b/persistence-modules/spring-data-jpa-4/pom.xml
index 8a476012c7..71fc21527f 100644
--- a/persistence-modules/spring-data-jpa-4/pom.xml
+++ b/persistence-modules/spring-data-jpa-4/pom.xml
@@ -33,6 +33,11 @@
mysql-connector-java
+
+ org.postgresql
+ postgresql
+
+
com.h2database
h2
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java
new file mode 100644
index 0000000000..cfb6e67c2c
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/Person.java
@@ -0,0 +1,35 @@
+package com.baeldung.namingstrategy;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Person {
+ @Id
+ private Long id;
+
+ private String firstName;
+
+ private String lastName;
+
+ public Person() {}
+
+ public Person(Long id, String firstName, String lastName) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ }
+
+ public Long id() {
+ return id;
+ }
+
+ public String firstName() {
+ return firstName;
+ }
+
+ public String lastName() {
+ return lastName;
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java
new file mode 100644
index 0000000000..3c7c25bbcb
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/PersonRepository.java
@@ -0,0 +1,6 @@
+package com.baeldung.namingstrategy;
+
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface PersonRepository extends JpaRepository {
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java
new file mode 100644
index 0000000000..16b01e50e3
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategy.java
@@ -0,0 +1,12 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
+
+public class QuotedLowerCaseNamingStrategy extends SpringPhysicalNamingStrategy {
+ @Override
+ protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) {
+ return new Identifier(name.toLowerCase(), true);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java
new file mode 100644
index 0000000000..3cb62aa5a2
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategy.java
@@ -0,0 +1,12 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
+
+public class QuotedUpperCaseNamingStrategy extends SpringPhysicalNamingStrategy {
+ @Override
+ protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) {
+ return new Identifier(name.toUpperCase(), true);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java
new file mode 100644
index 0000000000..f223015db8
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/SpringDataJpaNamingConventionApplication.java
@@ -0,0 +1,7 @@
+package com.baeldung.namingstrategy;
+
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class SpringDataJpaNamingConventionApplication {
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java
new file mode 100644
index 0000000000..69e96aee27
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategy.java
@@ -0,0 +1,12 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
+
+public class UnquotedLowerCaseNamingStrategy extends SpringPhysicalNamingStrategy {
+ @Override
+ protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) {
+ return new Identifier(name.toLowerCase(), false);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java
new file mode 100644
index 0000000000..cb87af10f4
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/main/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategy.java
@@ -0,0 +1,12 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.boot.model.naming.Identifier;
+import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
+
+public class UnquotedUpperCaseNamingStrategy extends SpringPhysicalNamingStrategy {
+ @Override
+ protected Identifier getIdentifier(String name, boolean quoted, JdbcEnvironment jdbcEnvironment) {
+ return new Identifier(name.toUpperCase(), false);
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java
new file mode 100644
index 0000000000..71a4dbda3f
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyH2IntegrationTest.java
@@ -0,0 +1,81 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("quoted-lower-case-naming-strategy.properties")
+class QuotedLowerCaseNamingStrategyH2IntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Unexpected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java
new file mode 100644
index 0000000000..6b1c984600
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedLowerCaseNamingStrategyPostgresLiveTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("quoted-lower-case-naming-strategy-on-postgres.properties")
+class QuotedLowerCaseNamingStrategyPostgresLiveTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java
new file mode 100644
index 0000000000..f819327a5c
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyH2IntegrationTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("quoted-upper-case-naming-strategy.properties")
+class QuotedUpperCaseNamingStrategyH2IntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenException(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java
new file mode 100644
index 0000000000..bd23b81b4b
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/QuotedUpperCaseNamingStrategyPostgresLiveTest.java
@@ -0,0 +1,81 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("quoted-upper-case-naming-strategy-on-postgres.properties")
+class QuotedUpperCaseNamingStrategyPostgresLiveTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Unexpected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java
new file mode 100644
index 0000000000..1850fea173
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyH2IntegrationTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("spring-physical-naming-strategy.properties")
+class SpringPhysicalNamingStrategyH2IntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Unexpected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Unexpected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java
new file mode 100644
index 0000000000..e26ebb148d
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/SpringPhysicalNamingStrategyPostgresLiveTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("spring-physical-naming-strategy-on-postgres.properties")
+class SpringPhysicalNamingStrategyPostgresLiveTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndSpringNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java
new file mode 100644
index 0000000000..6311c42e93
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyH2IntegrationTest.java
@@ -0,0 +1,86 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("unquoted-lower-case-naming-strategy.properties")
+class UnquotedLowerCaseNamingStrategyH2IntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Unexpected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Unexpected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java
new file mode 100644
index 0000000000..033a213cf5
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedLowerCaseNamingStrategyPostgresLiveTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("unquoted-lower-case-naming-strategy-on-postgres.properties")
+class UnquotedLowerCaseNamingStrategyPostgresLiveTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndLowerCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java
new file mode 100644
index 0000000000..7af8001854
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyH2IntegrationTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("unquoted-upper-case-naming-strategy.properties")
+class UnquotedUpperCaseNamingStrategyH2IntegrationTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Expected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java
new file mode 100644
index 0000000000..0151e7ece4
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/java/com/baeldung/namingstrategy/UnquotedUpperCaseNamingStrategyPostgresLiveTest.java
@@ -0,0 +1,85 @@
+package com.baeldung.namingstrategy;
+
+import org.hibernate.exception.SQLGrammarException;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.autoconfigure.jdbc.TestDatabaseAutoConfiguration;
+import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
+import org.springframework.test.context.TestPropertySource;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.Query;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@DataJpaTest(excludeAutoConfiguration = TestDatabaseAutoConfiguration.class)
+@TestPropertySource("unquoted-upper-case-naming-strategy-on-postgres.properties")
+class UnquotedUpperCaseNamingStrategyPostgresLiveTest {
+
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ @Autowired
+ private PersonRepository personRepository;
+
+ @BeforeEach
+ void insertPeople() {
+ personRepository.saveAll(Arrays.asList(
+ new Person(1L, "John", "Doe"),
+ new Person(2L, "Jane", "Doe"),
+ new Person(3L, "Ted", "Mosby")
+ ));
+ }
+
+ @ParameterizedTest
+ @ValueSource(strings = {"person", "PERSON", "Person"})
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonUnquoted_thenResult(String tableName) {
+ Query query = entityManager.createNativeQuery("select * from " + tableName);
+
+ // Expected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedUpperCase_thenException() {
+ Query query = entityManager.createNativeQuery("select * from \"PERSON\"");
+
+ // Unexpected result
+ assertThrows(SQLGrammarException.class, query::getResultStream);
+ }
+
+ @Test
+ void givenPeopleAndUpperCaseNamingStrategy_whenQueryPersonQuotedLowerCase_thenResult() {
+ Query query = entityManager.createNativeQuery("select * from \"person\"");
+
+ // Unexpected result
+ List result = (List) query.getResultStream()
+ .map(this::fromDatabase)
+ .collect(Collectors.toList());
+
+ assertThat(result).isNotEmpty();
+ }
+
+ public Person fromDatabase(Object databaseRow) {
+ Object[] typedDatabaseRow = (Object[]) databaseRow;
+
+ return new Person(
+ ((BigInteger) typedDatabaseRow[0]).longValue(),
+ (String) typedDatabaseRow[1],
+ (String) typedDatabaseRow[2]
+ );
+ }
+}
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties
new file mode 100644
index 0000000000..04b29de41f
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy-on-postgres.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/quoted-lower-case-strategy
+spring.datasource.username=postgres
+spring.datasource.password=root
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedLowerCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties
new file mode 100644
index 0000000000..6643c12c8a
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-lower-case-naming-strategy.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:quoted-lower-case-strategy
+spring.datasource.username=sa
+spring.datasource.password=
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedLowerCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties
new file mode 100644
index 0000000000..36898d5b4f
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy-on-postgres.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/quoted-upper-case-strategy
+spring.datasource.username=postgres
+spring.datasource.password=root
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedUpperCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties
new file mode 100644
index 0000000000..6d56d58749
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/quoted-upper-case-naming-strategy.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:quoted-upper-case-strategy
+spring.datasource.username=sa
+spring.datasource.password=
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.QuotedUpperCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties
new file mode 100644
index 0000000000..706b12b1b6
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy-on-postgres.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/spring-strategy
+spring.datasource.username=postgres
+spring.datasource.password=root
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=default-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties
new file mode 100644
index 0000000000..c9a0c6f24c
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/spring-physical-naming-strategy.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:spring-strategy
+spring.datasource.username=sa
+spring.datasource.password=
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=default-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties
new file mode 100644
index 0000000000..b22472bd8f
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy-on-postgres.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/unquoted-lower-case-strategy
+spring.datasource.username=postgres
+spring.datasource.password=root
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedLowerCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties
new file mode 100644
index 0000000000..8083515b4b
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-lower-case-naming-strategy.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:unquoted-lower-case-strategy
+spring.datasource.username=sa
+spring.datasource.password=
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedLowerCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties
new file mode 100644
index 0000000000..da03a0d7b5
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy-on-postgres.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:postgresql://localhost:5432/unquoted-upper-case-strategy
+spring.datasource.username=postgres
+spring.datasource.password=root
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedUpperCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file
diff --git a/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties
new file mode 100644
index 0000000000..d1b63e008c
--- /dev/null
+++ b/persistence-modules/spring-data-jpa-4/src/test/resources/com/baeldung/namingstrategy/unquoted-upper-case-naming-strategy.properties
@@ -0,0 +1,9 @@
+spring.datasource.url=jdbc:h2:mem:unquoted-upper-case-strategy
+spring.datasource.username=sa
+spring.datasource.password=
+
+spring.jpa.hibernate.ddl-auto=create-drop
+spring.jpa.hibernate.naming.physical-strategy=com.baeldung.namingstrategy.UnquotedUpperCaseNamingStrategy
+#spring.jpa.properties.javax.persistence.schema-generation.create-source=metadata
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.action=create
+#spring.jpa.properties.javax.persistence.schema-generation.scripts.create-target=upper-case-naming-strategy-ddl.sql
\ No newline at end of file