Hibernate

adplus-dvertising
SessionProvider is created for creating the object of session
Previous Home Next

Step 4:

SessionProvider is created for creating the object of session.

sessionProvider.java

package r4r;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class SessionProvider {
static SessionFactory factory;
static
{
Configuration cfg=new Configuration().configure();
factory=cfg.buildSessionFactory();
}
public static Session getSession() {
return factory.openSession();
}
}
Previous Home Next