Hibernate 最简单例子 (2)

     *inthedefaultpackage.Use#setConfigFile()toupdate

     *thelocationoftheconfigurationfileforthecurrentsession.  

     */

    privatestatic String CONFIG_FILE_LOCATION = "/hibernate.cfg.xml";

    privatestaticfinal ThreadLocal<Session> threadLocal = new ThreadLocal<Session>();

    private  static Configuration configuration = new Configuration();

    privatestatic org.hibernate.SessionFactory sessionFactory;

    privatestatic String configFile = CONFIG_FILE_LOCATION;

 

    static {

    try {

           configuration.configure(configFile);

           sessionFactory = configuration.buildSessionFactory();

        } catch (Exception e) {

           System.err

                  .println("%%%% Error Creating SessionFactory %%%%");

           e.printStackTrace();

       }

    }

    private HibernateSessionFactory() {

    }

   

    /**

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzjzyw.html