|
|
|
@ -21,6 +21,7 @@ import java.io.IOException; |
|
|
|
|
import java.util.Properties; |
|
|
|
|
import javax.sql.DataSource; |
|
|
|
|
|
|
|
|
|
import org.hibernate.Interceptor; |
|
|
|
|
import org.hibernate.SessionFactory; |
|
|
|
|
import org.hibernate.cfg.NamingStrategy; |
|
|
|
|
|
|
|
|
@ -69,6 +70,8 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res |
|
|
|
|
|
|
|
|
|
private Resource[] mappingDirectoryLocations; |
|
|
|
|
|
|
|
|
|
private Interceptor entityInterceptor; |
|
|
|
|
|
|
|
|
|
private NamingStrategy namingStrategy; |
|
|
|
|
|
|
|
|
|
private Properties hibernateProperties; |
|
|
|
@ -178,6 +181,16 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res |
|
|
|
|
this.mappingDirectoryLocations = mappingDirectoryLocations; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set a Hibernate entity interceptor that allows to inspect and change |
|
|
|
|
* property values before writing to and reading from the database. |
|
|
|
|
* Will get applied to any new Session created by this factory. |
|
|
|
|
* @see org.hibernate.cfg.Configuration#setInterceptor |
|
|
|
|
*/ |
|
|
|
|
public void setEntityInterceptor(Interceptor entityInterceptor) { |
|
|
|
|
this.entityInterceptor = entityInterceptor; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Set a Hibernate NamingStrategy for the SessionFactory, determining the |
|
|
|
|
* physical column and table names given the info in the mapping document. |
|
|
|
@ -291,6 +304,10 @@ public class LocalSessionFactoryBean implements FactoryBean<SessionFactory>, Res |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.entityInterceptor != null) { |
|
|
|
|
sfb.setInterceptor(this.entityInterceptor); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (this.namingStrategy != null) { |
|
|
|
|
sfb.setNamingStrategy(this.namingStrategy); |
|
|
|
|
} |
|
|
|
|