• 大小: 16.03MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-26
  • 语言: 其他
  • 标签: struts  hibernate  

资源简介

该系统为struts+hibernate做的一个完整的网上购书系统,很值得参考学习。解压后直接导入,将hibernate.cfg.xml中的<!-- create -->注解去掉,跑一遍程序后再加上,这样数据库表会自动生成

资源截图

代码片段和文件信息

package eshop;


import org.hibernate.cfg.*;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;



public class HibernateUtil {
    public static final SessionFactory sessionFactory;
         static {
               try {
                    sessionFactory = new Configuration().configure()
                              .buildSessionFactory();
               } catch (Throwable ex) {
                    throw new ExceptionInInitializerError(ex);
         }
    }
    public static final ThreadLocal session =
                            new ThreadLocal();

    public static Session currentSession() throws HibernateException {
          Session s = session.get();
          if(s == null) {
                s = sessionFactory.openSession();
                session.set(s);
          }
          return s;
    }
    public static void closeSession() throws HibernateException {
          Session s = session.get();
          if(s != null) {
                s.close();
          }
          session.set(null);
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       3727  2009-08-15 21:27  EShop\.classpath

     文件        288  2009-08-15 21:27  EShop\.mymetadata

     文件       1223  2009-08-15 21:27  EShop\.project

     文件         90  2009-08-16 10:06  EShop\.settings\org.eclipse.core.resources.prefs

     文件       1143  2009-08-15 21:27  EShop\src\eshop\action\AddtoCart.java

     文件        408  2009-08-15 21:27  EShop\src\eshop\action\admin\AdminAddItem-validation.xml

     文件        943  2009-08-15 21:27  EShop\src\eshop\action\admin\AdminAddItem.java

     文件       1113  2009-08-15 21:27  EShop\src\eshop\action\admin\AdminDeleteItem.java

     文件       1880  2009-08-15 21:27  EShop\src\eshop\action\admin\AdminLogin.java

     文件        846  2009-08-15 21:27  EShop\src\eshop\action\ChangeinfAction.java

     文件       1586  2009-08-15 21:27  EShop\src\eshop\action\CheckOut.java

     文件       1098  2009-08-15 21:27  EShop\src\eshop\action\DeletefromCart.java

     文件       1455  2009-08-15 21:27  EShop\src\eshop\action\DisplayCart.java

     文件        847  2009-08-15 21:27  EShop\src\eshop\action\InsertAction.java

     文件        464  2009-08-15 21:27  EShop\src\eshop\action\LogginAction-validation.xml

     文件       1637  2009-08-15 21:27  EShop\src\eshop\action\LogginAction.java

     文件       1139  2009-08-15 21:27  EShop\src\eshop\action\LogOut.java

     文件       1406  2009-08-15 21:27  EShop\src\eshop\action\PageManage.java

     文件        846  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectHome.java

     文件        325  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectRegister.java

     文件        797  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectToAdminAddItem.java

     文件       2591  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectToAdminDeleteItem.java

     文件        333  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectToAdminLogin.java

     文件        260  2009-08-15 21:27  EShop\src\eshop\action\redirect\RedirectToUserRegister.java

     文件       1688  2009-08-15 21:27  EShop\src\eshop\action\RegisterAction-validation.xml

     文件       1488  2009-08-15 21:27  EShop\src\eshop\action\RegisterAction.java

     文件       1318  2009-08-16 12:51  EShop\src\eshop\action\Report.java

     文件        964  2009-08-15 21:27  EShop\src\eshop\action\SeekAction.java

     文件       1651  2009-08-15 21:27  EShop\src\eshop\action\ShowClass.java

     文件        601  2009-08-15 21:27  EShop\src\eshop\action\UpdateinfAction-validation.xml

............此处省略240个文件信息

评论

共有 条评论