Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
fbe53be6
Commit
fbe53be6
authored
Apr 08, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish Hibernate 5 support
Closes gh-2763
parent
99dae09f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
19 deletions
+24
-19
JpaPropertiesTests.java
...mework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java
+14
-2
howto.adoc
spring-boot-docs/src/main/asciidoc/howto.adoc
+10
-12
SpringNamingStrategy.java
...ramework/boot/orm/jpa/hibernate/SpringNamingStrategy.java
+0
-5
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/JpaPropertiesTests.java
View file @
fbe53be6
...
...
@@ -26,6 +26,7 @@ import org.junit.After;
import
org.junit.Test
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.orm.jpa.hibernate.SpringNamingStrategy
;
import
org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
...
...
@@ -53,6 +54,18 @@ public class JpaPropertiesTests {
}
}
@Test
public
void
hibernate4NoCustomNamingStrategy
()
throws
Exception
{
JpaProperties
properties
=
load
(
HibernateVersion
.
V4
);
Map
<
String
,
String
>
hibernateProperties
=
properties
.
getHibernateProperties
(
mockStandaloneDataSource
());
assertThat
(
hibernateProperties
).
contains
(
entry
(
"hibernate.ejb.naming_strategy"
,
SpringNamingStrategy
.
class
.
getName
()));
assertThat
(
hibernateProperties
).
doesNotContainKeys
(
"hibernate.implicit_naming_strategy"
,
"hibernate.physical_naming_strategy"
);
}
@Test
public
void
hibernate4CustomNamingStrategy
()
throws
Exception
{
JpaProperties
properties
=
load
(
HibernateVersion
.
V4
,
...
...
@@ -163,8 +176,7 @@ public class JpaPropertiesTests {
ctx
.
register
(
TestConfiguration
.
class
);
ctx
.
refresh
();
this
.
context
=
ctx
;
JpaProperties
properties
=
this
.
context
.
getBean
(
JpaProperties
.
class
);
return
properties
;
return
this
.
context
.
getBean
(
JpaProperties
.
class
);
}
@Configuration
...
...
spring-boot-docs/src/main/asciidoc/howto.adoc
View file @
fbe53be6
...
...
@@ -1619,18 +1619,16 @@ configuration properties. The most common options to set are:
[indent=0,subs="verbatim,quotes,attributes"]
----
spring.jpa.hibernate.ddl-auto: create-drop
spring.jpa.hibernate.naming_strategy: org.hibernate.cfg.ImprovedNamingStrategy
spring.jpa.database: H2
spring.jpa.show-sql: true
----
(Because of relaxed data binding hyphens or underscores should work equally well as
property keys.) The `ddl-auto` setting is a special case in that it has different
defaults depending on whether you are using an embedded database (`create-drop`) or not
(`none`). In addition all properties in `+spring.jpa.properties.*+` are passed through as
normal JPA properties (with the prefix stripped) when the local `EntityManagerFactory` is
created.
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.hibernate.naming.physical-strategy=com.example.MyPhysicalNamingStrategy
spring.jpa.database=H2
spring.jpa.show-sql=true
----
The `ddl-auto` setting is a special case in that it has different defaults depending on
whether you are using an embedded database (`create-drop`) or not (`none`). In addition
all properties in `+spring.jpa.properties.*+` are passed through as normal JPA properties
(with the prefix stripped) when the local `EntityManagerFactory` is created.
See {sc-spring-boot-autoconfigure}/orm/jpa/HibernateJpaAutoConfiguration.{sc-ext}[`HibernateJpaAutoConfiguration`]
and {sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[`JpaBaseConfiguration`]
...
...
spring-boot/src/main/java/org/springframework/boot/orm/jpa/hibernate/SpringNamingStrategy.java
View file @
fbe53be6
...
...
@@ -16,9 +16,7 @@
package
org
.
springframework
.
boot
.
orm
.
jpa
.
hibernate
;
import
org.hibernate.Hibernate
;
import
org.hibernate.cfg.ImprovedNamingStrategy
;
import
org.hibernate.cfg.NamingStrategy
;
import
org.hibernate.internal.util.StringHelper
;
import
org.springframework.util.Assert
;
...
...
@@ -33,10 +31,7 @@ import org.springframework.util.StringUtils;
* @author Phillip Webb
* @see "http://stackoverflow.com/questions/7689206/ejb3namingstrategy-vs-improvednamingstrategy-foreign-key-naming"
* @since 1.2.0
* @deprecated as of 1.4 since {@link NamingStrategy} is no longer used by
* {@link Hibernate}. Consider using {@link SpringPhysicalNamingStrategy}
*/
@Deprecated
@SuppressWarnings
(
"serial"
)
public
class
SpringNamingStrategy
extends
ImprovedNamingStrategy
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment