Hibernate

Create Session provider class
Previous Home Next

Step 4: Create Session provider class

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