91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3.84MB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2023-10-30
  • 語言: 數據庫
  • 標簽: struts2??

資源簡介

這是一個struts2+hibernate3.2+Mysql完整框架的例子,對于初學者很有幫助。

資源截圖

代碼片段和文件信息

package?org;

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

/**
?*?Configures?and?provides?access?to?Hibernate?sessions?tied?to?the
?*?current?thread?of?execution.??Follows?the?Thread?Local?Session
?*?pattern?see?{@link?http://hibernate.org/42.html?}.
?*/
public?class?HibernateSessionFactory?{

????/**?
?????*?Location?of?hibernate.cfg.xml?file.
?????*?Location?should?be?on?the?classpath?as?Hibernate?uses??
?????*?#resourceAsStream?style?lookup?for?its?configuration?file.?
?????*?The?default?classpath?location?of?the?hibernate?config?file?is?
?????*?in?the?default?package.?Use?#setConfigFile()?to?update?
?????*?the?location?of?the?configuration?file?for?the?current?session.???
?????*/
????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()?{
????}

/**
?????*?Returns?the?ThreadLocal?Session?instance.??Lazy?initialize
?????*?the?SessionFactory?if?needed.
?????*
?????*??@return?Session
?????*??@throws?HibernateException
?????*/
????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;
????}

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

/**
?????*??Close?the?single?hibernate?session?instance.
?????*
?????*??@throws?HibernateException
?????*/
????public?static?void?closeSession()?throws?HibernateException?{
????????Session?session?=?(Session)?threadLocal.get();
????????threadLocal.set(null);

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

/**
?????*??return?session?factory
?????*
?????*/
public?static?org.hibernate.SessionFactory?getSessionFactory()?{
return?sessionFactory;
}

/**
?????*??return?session?factory
?????*
?????* session?factory?will?be?rebuil

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????848??2008-08-22?09:27??bookstore\.classpath

?????文件????????466??2008-08-22?09:27??bookstore\.myhibernatedata

?????文件????????300??2008-08-22?09:27??bookstore\.mymetadata

?????文件???????1429??2008-08-22?09:27??bookstore\.project

?????文件???????4743??2008-08-22?09:27??bookstore\src\bookstore.sql

?????文件???????1134??2008-08-22?09:27??bookstore\src\hibernate.cfg.xml

?????文件????????653??2008-08-22?09:27??bookstore\src\org\dao\IbaseDao.java

?????文件????????556??2008-08-22?09:27??bookstore\src\org\dao\IBookDao.java

?????文件???????5171??2008-08-22?09:27??bookstore\src\org\dao\impl\baseDaoImpl.java

?????文件???????1294??2008-08-22?09:27??bookstore\src\org\dao\impl\BookDaoImpl.java

?????文件???????1343??2008-08-22?09:27??bookstore\src\org\dao\impl\OrderDaoImpl.java

?????文件???????1529??2008-08-22?09:27??bookstore\src\org\dao\impl\UserDaoImpl.java

?????文件????????261??2008-08-22?09:27??bookstore\src\org\dao\IOrderDao.java

?????文件????????565??2008-08-22?09:27??bookstore\src\org\dao\UserDao.java

?????文件???????3317??2008-08-22?09:27??bookstore\src\org\HibernateSessionFactory.java

?????文件???????2226??2008-08-22?09:27??bookstore\src\org\model\Bookinfo.hbm.xml

?????文件???????3143??2008-08-22?09:27??bookstore\src\org\model\Bookinfo.java

?????文件???????1553??2008-08-22?09:27??bookstore\src\org\model\Order.hbm.xml

?????文件???????1985??2008-08-22?09:27??bookstore\src\org\model\Order.java

?????文件????????841??2008-08-22?09:27??bookstore\src\org\model\Rebate.hbm.xml

?????文件????????905??2008-08-22?09:27??bookstore\src\org\model\Rebate.java

?????文件???????1265??2008-08-22?09:27??bookstore\src\org\model\Remark.hbm.xml

?????文件???????1507??2008-08-22?09:27??bookstore\src\org\model\Remark.java

?????文件???????1909??2008-08-22?09:27??bookstore\src\org\model\Userinfo.hbm.xml

?????文件???????2559??2008-08-22?09:27??bookstore\src\org\model\Userinfo.java

?????文件???????3034??2008-08-22?09:27??bookstore\src\org\web\BookAction.java

?????文件???????5247??2008-08-22?09:27??bookstore\src\org\web\CartAction.java

?????文件???????1898??2008-08-22?09:27??bookstore\src\org\web\IndexAction.java

?????文件???????1200??2008-08-22?09:27??bookstore\src\org\web\interceptor\AuthenticationInterceptor.java

?????文件???????1199??2008-08-22?09:27??bookstore\src\org\web\paging\PageInfo.java

............此處省略112個文件信息

評論

共有 條評論