Im new using hibernate..I created a small applications usinf richfaces, jsf, hibernate...
Its working, but when I check the list of connections to Postgresql, my application generates to many..why? do I need to configure something in hibernate?
this is my bean that popules a rich:dataTable
Code:
public class DatosListaBean {
private List<Casos_soporte> listaDatos;
private static SessionFactory sessionFactory;
public void cargarLista(){
sessionFactory=new Configuration().configure().buildSessionFactory();
Session sesion=sessionFactory.openSession();
listaDatos= (List<Casos_soporte>)(sesion.createQuery("from Casos_soporte").list());
sesion.close();
}
public List<Casos_soporte> getListaDatos() {
cargarLista();
return listaDatos;
}
public void setListaDatos(List<Casos_soporte> listaDatos) {
this.listaDatos = listaDatos;
}
}
This is my cfg.xml file
Code:
<session-factory>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost/xxx</property>
<property name="hibernate.connection.username">xxx</property>
<property name="hibernate.connection.password">xxx</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.hbm2ddl.auto" >update</property>
<mapping resource="persistencia/casos_soporte.hbm.xml"/>
</session-factory>
how can i configure this so that it wont create 5+ connections to my DB..every time the page loads..