added "namingStrategy" property to Hibernate 4 LocalSessionFactoryBean variant (SPR-8864)
This commit is contained in:
parent
f50f3d2405
commit
93db3df35b
|
|
@ -22,6 +22,7 @@ import java.util.Properties;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
import org.hibernate.SessionFactory;
|
||||||
|
import org.hibernate.cfg.NamingStrategy;
|
||||||
|
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
@ -68,6 +69,8 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
|
||||||
|
|
||||||
private Resource[] mappingDirectoryLocations;
|
private Resource[] mappingDirectoryLocations;
|
||||||
|
|
||||||
|
private NamingStrategy namingStrategy;
|
||||||
|
|
||||||
private Properties hibernateProperties;
|
private Properties hibernateProperties;
|
||||||
|
|
||||||
private Class<?>[] annotatedClasses;
|
private Class<?>[] annotatedClasses;
|
||||||
|
|
@ -175,6 +178,15 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res
|
||||||
this.mappingDirectoryLocations = mappingDirectoryLocations;
|
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".
|
* Set Hibernate properties, such as "hibernate.dialect".
|
||||||
* <p>Note: Do not specify a transaction provider here when using
|
* <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) {
|
if (this.hibernateProperties != null) {
|
||||||
sfb.addProperties(this.hibernateProperties);
|
sfb.addProperties(this.hibernateProperties);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue