Browse Source

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

pull/7/head
Juergen Hoeller 13 years ago
parent
commit
93db3df35b
  1. 16
      org.springframework.orm/src/main/java/org/springframework/orm/hibernate4/LocalSessionFactoryBean.java

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

@ -22,6 +22,7 @@ import java.util.Properties; @@ -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 @@ -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 @@ -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 @@ -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);
}

Loading…
Cancel
Save