Skip to content

Commit 6a2332d

Browse files
committed
Merge branch '2.3.x'
Closes gh-24062
2 parents 946be4e + 44d0ce5 commit 6a2332d

File tree

2 files changed

+51
-3
lines changed

2 files changed

+51
-3
lines changed

spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1827,10 +1827,12 @@ The fully qualified class name of the physical and the implicit strategy impleme
18271827
Alternatively, if `ImplicitNamingStrategy` or `PhysicalNamingStrategy` beans are available in the application context, Hibernate will be automatically configured to use them.
18281828

18291829
By default, Spring Boot configures the physical naming strategy with `SpringPhysicalNamingStrategy`.
1830-
This implementation provides the same table structure as Hibernate 4: all dots are replaced by underscores and camel casing is replaced by underscores as well.
1831-
By default, all table names are generated in lower case, but it is possible to override that flag if your schema requires it.
1830+
This implementation provides the same table structure as Hibernate 4: all dots are replaced by underscores and camel casing is replaced by underscores as well. Additionally, by default, all table names are generated in lower case. For example, a `TelephoneNumber` entity is mapped to the `telephone_number` table. If your schema requires mixed-case identifiers, define a custom `SpringPhysicalNamingStrategy` bean, as shown in the following example:
18321831

1833-
For example, a `TelephoneNumber` entity is mapped to the `telephone_number` table.
1832+
[source,java,indent=0]
1833+
----
1834+
include::{code-examples}/jpa/CaseSensitiveSpringPhysicalNamingStrategyExample.java[tag=naming-strategy]
1835+
----
18341836

18351837
If you prefer to use Hibernate 5's default instead, set the following property:
18361838

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2012-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.docs.jpa;
18+
19+
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
20+
21+
import org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy;
22+
import org.springframework.context.annotation.Bean;
23+
24+
/**
25+
* Example configuration for defining a custom {@link SpringPhysicalNamingStrategy} that
26+
* is case sensitive.
27+
*
28+
* @author Andy Wilkinson
29+
*/
30+
class CaseSensitiveSpringPhysicalNamingStrategyExample {
31+
32+
// tag::naming-strategy[]
33+
@Bean
34+
SpringPhysicalNamingStrategy caseSensitivePhysicalNamingStrategy() {
35+
return new SpringPhysicalNamingStrategy() {
36+
37+
@Override
38+
protected boolean isCaseInsensitive(JdbcEnvironment jdbcEnvironment) {
39+
return false;
40+
}
41+
42+
};
43+
}
44+
// end::naming-strategy[]
45+
46+
}

0 commit comments

Comments
 (0)