Code example for SessionFactory

Methods: openSession

  protected final HibernateTemplate hibernateTemplate;
  static { 
    //turn off foreign keys for testing 
    sessionFactory = new Configuration().configure().buildSessionFactory();
    Session session = sessionFactory.openSession();
    session.doWork(new Work() {
      public void execute(Connection connection) throws SQLException {
        connection.createStatement().execute("SET DATABASE REFERENTIAL INTEGRITY FALSE;");
  public BaseHibernateTest() { 
    this.hibernateTemplate = new HibernateTemplate(sessionFactory);
Connect your IDE to all the code out there  Get Codota for Java