package com.jspdev.biyesheji.base;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Expression;
import org.hibernate.criterion.Order;
public abstract class _BaseRootDAO {
public _BaseRootDAO () {}
public _BaseRootDAO (Session session) {
setSession(session);
}
protected static Map<String, SessionFactory> sessionFactoryMap;
protected SessionFactory sessionFactory;
protected Session session;
protected final static ThreadLocal<Session> currentSession = new ThreadLocal<Session>();
/**
* Return a new Session object that must be closed when the work has been completed.
* @return the active Session
*/
public Session getSession() {
return getSession(
getConfigurationFileName());
}
/**
* Return a new Session object that must be closed when the work has been completed.
* @param configFile the config file must match the meta attribute "config-file" in the hibernate mapping file
* @return the active Session
*/
protected Session getSession(String configFile) {
if (null != session && session.isOpen()) return session;
else if (null != sessionFactory) {
Session s = currentSession.get();
if (null == s || !s.isOpen()) {
s = sessionFactory.openSession();
currentSession.set(s);
}
return s;
}
else {
Session s = currentSession.get();
if (null == s || !s.isOpen()) {
s = getSessionFactory(configFile).openSession();
currentSession.set(s);
}
return s;
}
}
public void setSession (Session session) {
this.session = session;
}
/**
* Configure the session factory by reading hibernate config file
*/
public static void initialize () {
com.jspdev.biyesheji.dao._RootDAO.initialize(
(String) null);
}
/**
* Configure the session factory by reading hibernate config file
* @param configFileName the name of the configuration file
*/
public static void initialize (String configFileName) {
com.jspdev.biyesheji.dao._RootDAO.initialize(
configFileName,
com.jspdev.biyesheji.dao._RootDAO.getNewConfiguration(
null));
}
public static void initialize (String configFileName, Configuration configuration) {
if (null != sessionFactoryMap && null != sessionFactoryMap.get(configFileName)) return;
else {
if (null == configFileName) {
configuration.configure();
com.jspdev.biyesheji.dao._RootDAO.setSessionFactory(
null,
configuration.buildSessionFactory());
}
else {
configuration.configure(
configFileName);
com.jspdev.biyesheji.dao._RootDAO.setSessionFactory(
configFileName,
configuration.buildSessionFactory());
}
}
}
/**
* Set the session factory
*/
public void setSessionFactory (SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
/**
* Set the session factory
*/
protected static void setSessionFactory (String configFileName, SessionFactory sf) {
if (null == configFileName) configFileName = "";
if (null == sessionFactoryMap) sessionFactoryMap = new HashMap<String, SessionFactory>();
sessionFactoryMap.put(
configFileName,
sf);
}
/**
* Return the SessionFactory that is to be used by these DAOs. Change this
* and implement your own strategy if you, for example, want to pull the SessionFactory
* from the JNDI tree.
*/
public SessionFactory getSessionFactory() {
if (null != sessionFactory) return sessionFactory;
else return getSessionFactory(
getConfigurationFileName());
}
public SessionFactory getSessionFactory(String configFileName) {
if (null == configFileName) configFileName = "";
if (null == sessionFactoryMap)
initialize(configFileName);
SessionFactory sf = (SessionFactory) sessionFactoryMap.get(configFileName);
if (null == sf)
throw new RuntimeException("The session factory for '" + configFileName + "' has not been initialized (or an error occured during initialization)");
else
return sf;
}
/**
* Close all sessions for the current thread
*/
public static void closeCurrentSession () {
Session s = currentSession.get();
if (null != s) {
if (s.isOpen()) s.close();
currentSession.set(null);
}
}
/**
* Close the session
*/
public void closeSession (Session session) {
if (null != session) session.close();
}
/**
* Begin the transaction related to the session
*/
public Transaction beginTransaction(Session s) {
return s.beginTransaction();
}
/**
* Commit the given transaction
*/
public void commitTransaction(Transaction t) {
t.commit();
}
/**
* Return a new Configuration to use. This is not a mistake and is meant
* to be overridden in the RootDAO if you want to do something different.
* The file name is passed in so you have that to access. The config file
* is read in the initialize method.
*/
public static Configuration getNewConfiguration (String configFileName) {
return new Configuration();
}
/**
* Return the name of the configuration file to be used with this DAO or null if default
*/
public String getConfigurationFileName () {
return null;
}
/**
* Return the specific Object class that will be used for class-specific
* implementation of this DAO.
* @return the reference Class
*/
protected abstract Class getReferenceClass();
/**
* Used by the base DAO classes but here for your modification
* Get object matching the given key and return it.
*/
protected Object get(Class refClass, Serializable key) {
Session s = null;
try {
s = getSession();
return get(refClass, key, s);
} finally {
closeSession(s);
}
}
/**
* Used by the base DAO classes but here for your modification
* Get object matching the given key and return it.
*/
protected Object get(Class refClass, Serializable key, Session s) {
return s.get(refClass, key);
}
/**
* Used by the base DAO classes but here for your modification
* Load object matching the given key and return it.
*/
protected Object load(Class refClass, Serializable key) {
Session s = null;
try {
s = getSession();
return load(refClass, key, s);
} finally {
closeSession(s);
}
}
/**
* Used by the base DAO classes but here for your modification
* Load object matching the given key and return it.
*/
protected Object load(Class refClass, Serializable key, Session s) {
return s.load(refClass, key);
}
/**
* Return all objects related to the implementation of this DAO with no filter.
*/
public java.util.List findAll () {
Session s = null;
try {
s = getSession();
return findAll(s);
}
finally {
closeSession(s);
}
}
/**
* Return all objects related to the implementation of this DAO with no filter.
* Use the session given.
* @param s the Session
*/
public java.util.List findAll (Session s) {
return findAll(s, getDefaultOrder());
}
/**
* Return all objects related to the implementation of this DAO with no filter.
*/
public java.util.List findAll (Order defaultOrder) {
Session s = null;
try {
s = getSession();
return findAll(s, defaultOrder);
}
finally {
closeSession(s);
}
}
/**
* Return all objects related to the implementation of this DAO with no filter.
* Use the session given.
* @param s the Session
*/
public java.util.List findAll (Session s, Order defaultOrder) {
Criteria crit = s.createCriteria(getReferenceClass());
if (nul
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一套相对完整的JSP毕业论文——教学管理系统,用JSP开发与实现动态网站的好范例,描述了J2EE的相关技术,比如Servlet,JSP,Struts,Hibernate等,并用这些技术完成一个基于Web的教学管理系统。 教学管理系统的开发过程是以软件工程的思想为指导,经过可行性研究、需求分析、总体分析、详细设计等主要阶段而进行的规范的开发过程。目前开发Web应用程序主要有C/S(客户机/服务器)和B/S(浏览器/服务器)两种模式。B/S设计模式为我们提供了系统设计的基本思想和基本方向。相对于C/S模式来讲,B/S 模式让客户端不安装软件通过对服务端的访问就可以得到所需信息,从而使网页更加便于浏览和管理,符合使用者对使用系统的要求,也就是说用户无需安装客户端,只要通过浏览器就可以访问相关服务;它在系统升级或维护的时候,只要在Web服务器中集中改动,用户在下一次页面刷新时就能立即得到反馈,而对于那些在服务端运行的逻辑、改动对于用户来说是透明的的;此外,就数据迁移和安全性等方面来讲,B/S模式也更加具有优势。 学校作为一个复杂的机构,要实现其日常教学活动庞大数据量的有效管理,借助于一个实用的教学管理系统是必不可少的。与教学活动相关的角色大致可分为学生、教师和教学管理人员三类。而这三类用户所具备的权限、所关心的问题及所需要的资料也互不相同,这就需要给他们提供不同的操作界面,规定他们的对应操作。因此,教学管理系统的主要功能也必须针对这三类主要角色进行相对应的设计。
资源推荐
资源详情
资源评论
收起资源包目录
教学管理系统论文(带源代码) (301个子文件)
_BaseRootDAO.class 15KB
Student.class 6KB
BaseStudent.class 5KB
Teacher.class 5KB
Sc.class 5KB
BaseStudentDAO.class 4KB
BaseTeacherDAO.class 4KB
BaseMessageDAO.class 4KB
BaseCourseDAO.class 4KB
BaseSc.class 4KB
Grade.class 4KB
BaseGradeDAO.class 4KB
BaseCourse.class 4KB
BaseScDAO.class 4KB
BaseNoteDAO.class 4KB
BaseTeacher.class 4KB
Course.class 4KB
Message.class 4KB
TeachersQueryAction.class 4KB
BaseMessage.class 3KB
BaseGrade.class 3KB
StudentsQueryAction.class 3KB
GradeQueryAction.class 3KB
StuInfoForm.class 3KB
CoursesQueryAction.class 3KB
GradeAction.class 3KB
addStudentServlet.class 3KB
BaseNote.class 2KB
HibernateSessionFactory.class 2KB
LoginAction.class 2KB
_BaseRootDAO$TransactionPointer.class 2KB
courseInfoServlet.class 2KB
addTeacherServlet.class 2KB
ScAction.class 2KB
_BaseRootDAO$ThreadRunner.class 2KB
f_tScServlet.class 2KB
t_fScServlet.class 2KB
TeaInfoForm.class 2KB
CourseForm.class 2KB
BaseGradePK.class 2KB
PasswordForm.class 2KB
PageControlServlet.class 2KB
deleteMessageServlet.class 2KB
GradeForm.class 2KB
changeGradeServlet.class 2KB
SignonFilter.class 2KB
MessageForm.class 2KB
CourseAction.class 2KB
PasswordAction.class 2KB
MessageAction.class 2KB
StudentsQueryForm.class 2KB
Note.class 2KB
deleteTeacherServlet.class 2KB
TeachersQueryForm.class 2KB
EncodingFilter.class 2KB
CancelScAction.class 1KB
GradeQueryForm.class 1KB
LoginForm.class 1KB
TeaInfoAction.class 1KB
StuInfoAction.class 1KB
CancelScForm.class 1KB
DeleteStudentsAction.class 1KB
DeleteTeachersAction.class 1KB
DeleteCoursesAction.class 1KB
CoursesQueryForm.class 1KB
NoteAction.class 1KB
ScForm.class 1KB
deleteStudentServlet.class 1KB
deleteCourseServlet.class 1KB
NoteForm.class 1KB
DeleteTeachersForm.class 1KB
DeleteStudentsForm.class 1KB
DeleteCoursesForm.class 1KB
_BaseRootDAO$4.class 1KB
_BaseRootDAO$1.class 1KB
_BaseRootDAO$2.class 997B
Page.class 994B
_BaseRootDAO$3.class 991B
_BaseRootDAO$5.class 991B
HibernateUtil.class 874B
_BaseRootDAO$TransactionRunnableFailHandler.class 773B
_BaseRootDAO$TransactionRunnable.class 679B
GradePK.class 628B
GradeDAO.class 543B
TeacherDAO.class 529B
StudentDAO.class 529B
MessageDAO.class 529B
CourseDAO.class 524B
TeacherDAO.class 519B
StudentDAO.class 519B
GradeDAO.class 519B
NoteDAO.class 514B
CourseDAO.class 513B
ScDAO.class 504B
NoteDAO.class 501B
_RootDAO.class 493B
MessageDAO.class 337B
ScDAO.class 317B
_BaseRootDAO$TransactionFailHandler.class 300B
.classpath 976B
共 301 条
- 1
- 2
- 3
- 4
fov
- 粉丝: 28
- 资源: 229
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页