Hi.
What are the best designs to have this "initialization" code?
Code:
Datastore ds = Hibernate.createDatastore();
ds.storeClass(User.class);
...
SessionFactory sf = ds.buildSessionFactory(); // or supply a Properties arg
Session session = sf.openSession();
The createDataStore() and storeClass() methods can be called only once for the application.
So I could call it on some kind of filter at the first request of my application for example. Right?
About the buildSessionFactory() method, can I call it only once for the application? And leave the sf obejct there available forever?
The openSession() method I could call before all my façade method just before the database access logic, right?
Thanks.
Hibernate version:anyone
Mapping documents:don`t apply
Code between sessionFactory.openSession() and session.close():don`t apply
Full stack trace of any exception that occurs:don`t apply
Name and version of the database you are using:doesn`t matter really