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
196b9c9b
Commit
196b9c9b
authored
Jun 08, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
be26cba0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
JpaProperties.java
...ngframework/boot/autoconfigure/orm/jpa/JpaProperties.java
+10
-7
RedisAutoConfiguration.java
...work/boot/autoconfigure/redis/RedisAutoConfiguration.java
+1
-1
CustomHibernateJpaAutoConfigurationTests.java
...ure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java
+7
-5
RedisAutoConfigurationTests.java
...boot/autoconfigure/redis/RedisAutoConfigurationTests.java
+2
-4
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java
View file @
196b9c9b
...
@@ -159,13 +159,8 @@ public class JpaProperties {
...
@@ -159,13 +159,8 @@ public class JpaProperties {
DataSource
dataSource
)
{
DataSource
dataSource
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>(
existing
);
Map
<
String
,
String
>
result
=
new
HashMap
<
String
,
String
>(
existing
);
if
(!
isAlreadyProvided
(
existing
,
"ejb.naming_strategy_delegator"
))
{
if
(!
isAlreadyProvided
(
existing
,
"ejb.naming_strategy_delegator"
))
{
if
(!
isAlreadyProvided
(
existing
,
"ejb.naming_strategy"
)
result
.
put
(
"hibernate.ejb.naming_strategy"
,
&&
this
.
namingStrategy
!=
null
)
{
getHibernateNamingStrategy
(
existing
));
result
.
put
(
"hibernate.ejb.naming_strategy"
,
this
.
namingStrategy
.
getName
());
}
else
if
(
this
.
namingStrategy
==
null
)
{
result
.
put
(
"hibernate.ejb.naming_strategy"
,
DEFAULT_NAMING_STRATEGY
);
}
}
}
String
ddlAuto
=
getOrDeduceDdlAuto
(
existing
,
dataSource
);
String
ddlAuto
=
getOrDeduceDdlAuto
(
existing
,
dataSource
);
if
(
StringUtils
.
hasText
(
ddlAuto
)
&&
!
"none"
.
equals
(
ddlAuto
))
{
if
(
StringUtils
.
hasText
(
ddlAuto
)
&&
!
"none"
.
equals
(
ddlAuto
))
{
...
@@ -177,6 +172,14 @@ public class JpaProperties {
...
@@ -177,6 +172,14 @@ public class JpaProperties {
return
result
;
return
result
;
}
}
private
String
getHibernateNamingStrategy
(
Map
<
String
,
String
>
existing
)
{
if
(!
isAlreadyProvided
(
existing
,
"ejb.naming_strategy"
)
&&
this
.
namingStrategy
!=
null
)
{
return
this
.
namingStrategy
.
getName
();
}
return
DEFAULT_NAMING_STRATEGY
;
}
private
String
getOrDeduceDdlAuto
(
Map
<
String
,
String
>
existing
,
private
String
getOrDeduceDdlAuto
(
Map
<
String
,
String
>
existing
,
DataSource
dataSource
)
{
DataSource
dataSource
)
{
String
ddlAuto
=
(
this
.
ddlAuto
!=
null
?
this
.
ddlAuto
String
ddlAuto
=
(
this
.
ddlAuto
!=
null
?
this
.
ddlAuto
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfiguration.java
View file @
196b9c9b
...
@@ -84,7 +84,7 @@ public class RedisAutoConfiguration {
...
@@ -84,7 +84,7 @@ public class RedisAutoConfiguration {
factory
.
setPassword
(
this
.
properties
.
getPassword
());
factory
.
setPassword
(
this
.
properties
.
getPassword
());
}
}
factory
.
setDatabase
(
this
.
properties
.
getDatabase
());
factory
.
setDatabase
(
this
.
properties
.
getDatabase
());
if
(
this
.
properties
.
getTimeout
()
>
0
)
{
if
(
this
.
properties
.
getTimeout
()
>
0
)
{
factory
.
setTimeout
(
this
.
properties
.
getTimeout
());
factory
.
setTimeout
(
this
.
properties
.
getTimeout
());
}
}
return
factory
;
return
factory
;
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/orm/jpa/CustomHibernateJpaAutoConfigurationTests.java
View file @
196b9c9b
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
package
org
.
springframework
.
boot
.
autoconfigure
.
orm
.
jpa
;
package
org
.
springframework
.
boot
.
autoconfigure
.
orm
.
jpa
;
import
java.util.Map
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
org.junit.After
;
import
org.junit.After
;
...
@@ -87,8 +89,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
...
@@ -87,8 +89,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
@Test
@Test
public
void
testNamingStrategyDelegatorTakesPrecedence
()
{
public
void
testNamingStrategyDelegatorTakesPrecedence
()
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
+
"spring.jpa.properties.hibernate.ejb.naming_strategy_delegator:"
"org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator"
);
+
"org.hibernate.cfg.naming.ImprovedNamingStrategyDelegator"
);
this
.
context
.
register
(
TestConfiguration
.
class
,
this
.
context
.
register
(
TestConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
EmbeddedDataSourceConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
,
...
@@ -96,8 +98,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
...
@@ -96,8 +98,8 @@ public class CustomHibernateJpaAutoConfigurationTests {
this
.
context
.
refresh
();
this
.
context
.
refresh
();
JpaProperties
bean
=
this
.
context
.
getBean
(
JpaProperties
.
class
);
JpaProperties
bean
=
this
.
context
.
getBean
(
JpaProperties
.
class
);
DataSource
dataSource
=
this
.
context
.
getBean
(
DataSource
.
class
);
DataSource
dataSource
=
this
.
context
.
getBean
(
DataSource
.
class
);
assertThat
(
bean
.
getHibernateProperties
(
dataSource
).
get
(
Map
<
String
,
String
>
hibernateProperties
=
bean
.
getHibernateProperties
(
dataSource
);
"hibernate.ejb.naming_strategy"
),
nullValue
());
assertThat
(
hibernateProperties
.
get
(
"hibernate.ejb.naming_strategy"
),
nullValue
());
}
}
@Configuration
@Configuration
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/redis/RedisAutoConfigurationTests.java
View file @
196b9c9b
...
@@ -89,8 +89,7 @@ public class RedisAutoConfigurationTests {
...
@@ -89,8 +89,7 @@ public class RedisAutoConfigurationTests {
load
(
"spring.redis.host:foo"
,
"spring.redis.timeout:100"
);
load
(
"spring.redis.host:foo"
,
"spring.redis.timeout:100"
);
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
assertEquals
(
"foo"
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
.
getHostName
());
.
getHostName
());
assertEquals
(
100
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
)
assertEquals
(
100
,
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getTimeout
());
.
getTimeout
());
}
}
@Test
@Test
...
@@ -145,8 +144,7 @@ public class RedisAutoConfigurationTests {
...
@@ -145,8 +144,7 @@ public class RedisAutoConfigurationTests {
this
.
context
=
doLoad
(
environment
);
this
.
context
=
doLoad
(
environment
);
}
}
private
AnnotationConfigApplicationContext
doLoad
(
private
AnnotationConfigApplicationContext
doLoad
(
String
...
environment
)
{
String
...
environment
)
{
AnnotationConfigApplicationContext
applicationContext
=
new
AnnotationConfigApplicationContext
();
AnnotationConfigApplicationContext
applicationContext
=
new
AnnotationConfigApplicationContext
();
EnvironmentTestUtils
.
addEnvironment
(
applicationContext
,
environment
);
EnvironmentTestUtils
.
addEnvironment
(
applicationContext
,
environment
);
applicationContext
.
register
(
RedisAutoConfiguration
.
class
,
applicationContext
.
register
(
RedisAutoConfiguration
.
class
,
...
...
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