AdmMono/src/com/rjconsultores/ventaboletos/utilerias/spring/MyAnnotationSessionFactoryB...

33 lines
1.1 KiB
Java

package com.rjconsultores.ventaboletos.utilerias.spring;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean;
import com.rjconsultores.ventaboletos.auditoria.interceptor.AuditInterceptor;
import com.rjconsultores.ventaboletos.dao.hibernate.sqlfunction.FnArredondamentoTarifa;
import com.rjconsultores.ventaboletos.dao.util.DBUtil;
@SuppressWarnings("deprecation")
public class MyAnnotationSessionFactoryBean extends AnnotationSessionFactoryBean{
public MyAnnotationSessionFactoryBean() {
super();
super.setEntityInterceptor(new AuditInterceptor());
}
protected void postProcessAnnotationConfiguration(AnnotationConfiguration config) throws HibernateException {
config.addSqlFunction("FN_ARREDONDAMENTO_TARIFA", new FnArredondamentoTarifa());
}
@Override
protected void afterSessionFactoryCreation() throws Exception {
DBUtil.getInstance().setSessionFactory(this.getSessionFactory());
super.afterSessionFactoryCreation();
}
}