|
22 | 22 | import javax.sql.DataSource;
|
23 | 23 |
|
24 | 24 | import org.hibernate.SessionFactory;
|
| 25 | +import org.hibernate.cfg.NamingStrategy; |
25 | 26 |
|
26 | 27 | import org.springframework.beans.factory.DisposableBean;
|
27 | 28 | import org.springframework.beans.factory.FactoryBean;
|
@@ -68,6 +69,8 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
|
68 | 69 |
|
69 | 70 | private Resource[] mappingDirectoryLocations;
|
70 | 71 |
|
| 72 | + private NamingStrategy namingStrategy; |
| 73 | + |
71 | 74 | private Properties hibernateProperties;
|
72 | 75 |
|
73 | 76 | private Class<?>[] annotatedClasses;
|
@@ -175,6 +178,15 @@ public void setMappingDirectoryLocations(Resource[] mappingDirectoryLocations) {
|
175 | 178 | this.mappingDirectoryLocations = mappingDirectoryLocations;
|
176 | 179 | }
|
177 | 180 |
|
| 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 | + |
178 | 190 | /**
|
179 | 191 | * Set Hibernate properties, such as "hibernate.dialect".
|
180 | 192 | * <p>Note: Do not specify a transaction provider here when using
|
@@ -279,6 +291,10 @@ public void afterPropertiesSet() throws IOException {
|
279 | 291 | }
|
280 | 292 | }
|
281 | 293 |
|
| 294 | + if (this.namingStrategy != null) { |
| 295 | + sfb.setNamingStrategy(this.namingStrategy); |
| 296 | + } |
| 297 | + |
282 | 298 | if (this.hibernateProperties != null) {
|
283 | 299 | sfb.addProperties(this.hibernateProperties);
|
284 | 300 | }
|
|
0 commit comments