• 大小: 497KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-06-05
  • 语言: 其他
  • 标签: jsf  成绩管理  

资源简介

由于受到上传大小限制,本人把class里类库去掉了,希望下载者自行添加

资源截图

代码片段和文件信息

package org.xmh;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.cfg.Configuration;

public class HibernateSessionFactory {

    private static String CONFIG_FILE_LOCATION = “/hibernate.cfg.xml“;
private static final ThreadLocal threadLocal = new ThreadLocal();
    private  static Configuration configuration = new Configuration();
    private static org.hibernate.SessionFactory sessionFactory;
    private static 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() {
    }

    public static Session getSession() throws HibernateException {
        Session session = (Session) threadLocal.get();

if (session == null || !session.isOpen()) {
if (sessionFactory == null) {
rebuildSessionFactory();
}
session = (sessionFactory != null) ? sessionFactory.openSession()
: null;
threadLocal.set(session);
}

        return session;
    }

public static void rebuildSessionFactory() {
try {
configuration.configure(configFile);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err
.println(“%%%% Error Creating SessionFactory %%%%“);
e.printStackTrace();
}
}

    public static void closeSession() throws HibernateException {
        Session session = (Session) threadLocal.get();
        threadLocal.set(null);

        if (session != null) {
            session.close();
        }
    }

public static org.hibernate.SessionFactory getSessionFactory() {
return sessionFactory;
}

public static void setConfigFile(String configFile) {
HibernateSessionFactory.configFile = configFile;
sessionFactory = null;
}

public static Configuration getConfiguration() {
return configuration;
}

}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2011-07-26 07:58  新\
     目录           0  2011-07-25 20:49  新\新\
     目录           0  2011-07-25 14:59  新\新\14\
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\
     文件        3223  2007-11-13 12:19  新\新\14\stujshdemo\.classpath
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\.myeclipse\
     文件         446  2007-11-08 10:18  新\新\14\stujshdemo\.myhibernatedata
     文件         303  2008-01-31 22:54  新\新\14\stujshdemo\.mymetadata
     文件        1430  2007-11-08 11:22  新\新\14\stujshdemo\.project
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\.settings\
     文件        1047  2007-11-15 14:10  新\新\14\stujshdemo\.settings\org.eclipse.jdt.core.prefs
     文件         260  2007-11-15 14:10  新\新\14\stujshdemo\.settings\org.eclipse.jdt.ui.prefs
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\
     文件        1004  2007-11-09 08:42  新\新\14\stujshdemo\src\hibernate.cfg.xml
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\dao\
     文件         464  2007-11-09 01:22  新\新\14\stujshdemo\src\org\xmh\dao\IAdminDao.java
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\dao\impl\
     文件        3266  2007-11-09 02:38  新\新\14\stujshdemo\src\org\xmh\dao\impl\AdminDaoImpl.java
     文件        2321  2007-11-09 02:37  新\新\14\stujshdemo\src\org\xmh\dao\impl\StuClassDaoImpl.java
     文件        3142  2007-12-03 20:19  新\新\14\stujshdemo\src\org\xmh\dao\impl\StudentDaoImpl.java
     文件         351  2007-11-08 10:21  新\新\14\stujshdemo\src\org\xmh\dao\IStuClassDao.java
     文件         425  2007-11-09 05:27  新\新\14\stujshdemo\src\org\xmh\dao\IStudentDao.java
     文件        2098  2007-11-14 19:52  新\新\14\stujshdemo\src\org\xmh\HibernateSessionFactory.java
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\model\
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\model\exceptions\
     文件         282  2007-11-08 10:34  新\新\14\stujshdemo\src\org\xmh\model\exceptions\MyException.java
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\model\service\
     文件         598  2007-11-09 04:29  新\新\14\stujshdemo\src\org\xmh\model\service\IAdminService.java
     目录           0  2011-07-25 14:59  新\新\14\stujshdemo\src\org\xmh\model\service\impl\
............此处省略82个文件信息

评论

共有 条评论