public SessionFactory getSessionFactory() throws HibernateException { return cfg.buildSessionFactory(); }
SessionFactory buildSessionFactory() throws HibernateException { return cfg.buildSessionFactory(); }
public static synchronized Session getSession() { if (sessionFactory == null) sessionFactory = new AnnotationConfiguration().configure(configuration).buildSessionFactory(); return sessionFactory.openSession(); }
public SessionFactory getFactory() { try { if (factory == null) { factory = new AnnotationConfiguration().configure() .buildSessionFactory(); } else if (factory.isClosed()) { factory = new AnnotationConfiguration().configure() .buildSessionFactory(); } } catch (Exception e) { LOG.error("Exception in getFactory while creating new Factory M:" + e.getMessage() + " C: " + e.getCause() + " ST: " + e.getStackTrace()); } return factory; }
public EntityManagerFactory buildEntityManagerFactory() { Thread thread = null; ClassLoader contextClassLoader = null; if (overridenClassLoader != null) { thread = Thread.currentThread(); contextClassLoader = thread.getContextClassLoader(); thread.setContextClassLoader( overridenClassLoader ); } try { configure( (Properties)null, null ); NamingHelper.bind(this); return new EntityManagerFactoryImpl( cfg.buildSessionFactory(), transactionType, discardOnClose, getSessionInterceptorClass( cfg.getProperties() ) ); } catch (HibernateException e) { throw new PersistenceException( getExceptionHeader() + "Unable to build EntityManagerFactory", e ); } finally { if (thread != null) { thread.setContextClassLoader( contextClassLoader ); } } }
/** * Instantiates a new DBResultHelper. */ public DBResultHelper() { AnnotationConfiguration conf = new AnnotationConfiguration() .addAnnotatedClass(TestClass.class) .addAnnotatedClass(TestInstance.class) .addAnnotatedClass(TestMethod.class) .addAnnotatedClass(Group.class) .addAnnotatedClass(MethodType.class) .addAnnotatedClass(TestMethodException.class) .addAnnotatedClass(Suite.class).addAnnotatedClass(Test.class); // TODO make configuration accessible to a library user conf.configure("/hibernate.cfg.xml"); factory = conf.buildSessionFactory(); }
return config.buildSessionFactory();