Skip to content

Commit 93db3df

Browse files
committed
added "namingStrategy" property to Hibernate 4 LocalSessionFactoryBean variant (SPR-8864)
1 parent f50f3d2 commit 93db3df

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

org.springframework.orm/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import javax.sql.DataSource;
2323

2424
import org.hibernate.SessionFactory;
25+
import org.hibernate.cfg.NamingStrategy;
2526

2627
import org.springframework.beans.factory.DisposableBean;
2728
import org.springframework.beans.factory.FactoryBean;
@@ -68,6 +69,8 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
6869

6970
private Resource[] mappingDirectoryLocations;
7071

72+
private NamingStrategy namingStrategy;
73+
7174
private Properties hibernateProperties;
7275

7376
private Class<?>[] annotatedClasses;
@@ -175,6 +178,15 @@ public void setMappingDirectoryLocations(Resource[] mappingDirectoryLocations) {
175178
this.mappingDirectoryLocations = mappingDirectoryLocations;
176179
}
177180

181+
/**
182+
* Set a Hibernate NamingStrategy for the SessionFactory, determining the
183+
* physical column and table names given the info in the mapping document.
184+
* @see org.hibernate.cfg.Configuration#setNamingStrategy
185+
*/
186+
public void setNamingStrategy(NamingStrategy namingStrategy) {
187+
this.namingStrategy = namingStrategy;
188+
}
189+
178190
/**
179191
* Set Hibernate properties, such as "hibernate.dialect".
180192
* <p>Note: Do not specify a transaction provider here when using
@@ -279,6 +291,10 @@ public void afterPropertiesSet() throws IOException {
279291
}
280292
}
281293

294+
if (this.namingStrategy != null) {
295+
sfb.setNamingStrategy(this.namingStrategy);
296+
}
297+
282298
if (this.hibernateProperties != null) {
283299
sfb.addProperties(this.hibernateProperties);
284300
}

0 commit comments

Comments
 (0)