added "namingStrategy" property to Hibernate 4 LocalSessionFactoryBean variant (SPR-8864)

This commit is contained in:
Juergen Hoeller 2011-11-28 00:04:55 +00:00
parent f50f3d2405
commit 93db3df35b
1 changed files with 16 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import java.util.Properties;
import javax.sql.DataSource;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.NamingStrategy;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.FactoryBean;
@ -68,6 +69,8 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
private Resource[] mappingDirectoryLocations;
private NamingStrategy namingStrategy;
private Properties hibernateProperties;
private Class<?>[] annotatedClasses;
@ -175,6 +178,15 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
this.mappingDirectoryLocations = mappingDirectoryLocations;
}
/**
* Set a Hibernate NamingStrategy for the SessionFactory, determining the
* physical column and table names given the info in the mapping document.
* @see org.hibernate.cfg.Configuration#setNamingStrategy
*/
public void setNamingStrategy(NamingStrategy namingStrategy) {
this.namingStrategy = namingStrategy;
}
/**
* Set Hibernate properties, such as "hibernate.dialect".
* <p>Note: Do not specify a transaction provider here when using
@ -279,6 +291,10 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
}
}
if (this.namingStrategy != null) {
sfb.setNamingStrategy(this.namingStrategy);
}
if (this.hibernateProperties != null) {
sfb.addProperties(this.hibernateProperties);
}