Esempio n. 1
0
    static
    {
        try
        {

            InputStream stream = Thread.currentThread().getContextClassLoader().getResource("hibernate.properties").openStream();// Example.class.getResourceAsStream("hibernate.properties");
            try
            {
                pops.load(stream);
            }
            catch (IOException e1)
            {
                e1.printStackTrace();
            }
            Configuration cfg = new Configuration();
            cfg.addClass(Person.class);
            cfg.setProperties(pops);
            _sessions = cfg.buildSessionFactory();
            if (_sessions == null)
            {
                System.out.println("This _session is nULLL");
            }
        }
        catch (MappingException e)
        {
            e.printStackTrace();
        }
        catch (HibernateException e)
        {
            e.printStackTrace();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

    }
 private void initHibernate() throws MappingException, HibernateException {
   Configuration cfg = new Configuration();
   cfg.addJar("retsdb2-hbm-xml.jar");
   mSessions = cfg.buildSessionFactory();
 }