资源目录
压缩包内文档预览:(预览前20页/共116页)
编号:32963805
类型:共享资源
大小:18.04MB
格式:ZIP
上传时间:2019-12-13
上传人:遗****
认证信息
个人认证
刘**(实名认证)
湖北
IP属地:湖北
30
积分
- 关 键 词:
-
皖北书
城管
系统
- 资源描述:
-
皖北书城管理系统二,皖北书,城管,系统
- 内容简介:
-
皖北书城管理系统 个人介绍 学院 计算机学院姓名 黄修海学号 049074039班级 计042指导老师 陆勤老师同组人员 邢阿亮陶金 研究背景 就书城系统而言 由于网络已经覆盖全球 信息量大而独具优势 售书的理念也很简单 就是读者可以自己寻找自己喜爱的书为替读者找寻他们想要的书 办公自动化对企业来讲是非常重要的 传统的手工式管理已经无法满足当今企业的需要 随着现代科技的不断发展 办公自动化管理方面的软件已经成为企业不可或缺的办公平台 可行性 技术可行性皖北书城管理系统 可以基于WEB平台 采用Java语言 数据量小 只需采用小型数据库MySql 实现过程中可以用Hibernate等连接数据库 并可以使用建立专门的实体类与数据库的相应表进行映射 通过对实体类的业务实现来控制数据库的表 从而实现了数据库的增加 删除 插入等操作 功能实现不复杂 操作可行性本人力皖北书城管理系统的开发环境为Linux 投入Windows环境中使用 开发语言为Java Eclipse MyEclipse插件 后台数据库用MySql来实现 系统采用B S模式 用户只需了解Windows基本操作就可以很好地使用本系统 因此 在操作的可行性上不存在任何问题 意义 开办网上书城系统也可以为在校大学生提供方便 廉价 高效的书城方式 促进文化传播 帮助国家和学校培养优秀的人才 具有长远的社会效益和经济效益 后台管理也为公司节省不少人力 物力 才力 技术介绍 EclipseEclipse是一个开放源代码的 基于Java的可扩展开发平台 就其本身而言 它只是一个框架和一组服务 用于通过插件组件构建开发环境 幸运的是 Eclipse附带了一个标准的插件集 包括Java开发工具 JavaDevelopmentTools JDT Eclipse还包括插件开发环境 Plug inDevelopmentEnvironment PDE 这个组件主要针对希望扩展Eclipse的软件开发人员 因为它允许他们构建与Eclipse环境无缝集成的工具 MyEclipseMyEclipse企业级工作平台 MyEclipseEnterpriseWorkbench 简称MyEclipse 是对EclipseIDE的扩展 利用它我们可以在数据库和J2EE的开发 发布 以及应用程序服务器的整合方面极大的提高工作效率 它是功能丰富的J2EE集成开发环境 包括了完备的编码 调试 测试和发布功能 完整支持HTML Struts JSF CSS Javascript SQL Hibernate Apache tomcatTomcat是Apache软件基金会 ApacheSoftwareFoundation 的Jakarta项目中的一个核心项目 由Apache Sun和其他一些公司及个人共同开发而成 由于有了Sun的参与和支持 最新的Servlet和JSP规范总是能在Tomcat中得到体现 Tomcat5支持最新的Servlet2 4和JSP2 0规范 因为Tomcat技术先进 性能稳定 而且免费 因而深受Java爱好者的喜爱并得到了部分软件开发商的认可 成为目前比较流行的Web应用服务器 JspJSP JavaServerPages 是由SunMicrosystems公司倡导 许多公司参与一起建立的一种动态网页技术标准 JSP技术有点类似ASP技术 它是在传统的网页HTML文件 htm html 中插入Java程序段 Scriptlet 和JSP标记 tag 从而形成JSP文件 jsp StrutsStruts最早是作为ApacheJakarta项目的组成部分问世运作 项目的创立者希望通过对该项目的研究 改进和提高JavaServerPages Servlet 标签库以及面向对象的技术水准 HibernateHibernate是一个开放源代码的对象关系映射框架 它对JDBC进行了非常轻量级的对象封装 使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库 Hibernate可以应用在任何使用JDBC的场合 既可以在Java的客户端程序使用 也可以在Servlet JSP的Web应用中使用 最具革命意义的是 Hibernate可以在应用EJB的J2EE架构中取代CMP 完成数据持久化的重任 系统的整体设计 皖北书城管理系统 库存管理 销售管理 财务管理 客服管理 采购管理 系统管理 人员管理 模块分析 人员管理人员管理模块用于公司员工信息的统一管理包含的功能如图 人员管理 员工信息管理 员工考勤 员工信息管理 员工信息管理 添加新员工 修改员工信息 删除员工记录 考勤管理 员工考勤管理 考勤 修改考勤信息 考勤信息删除 库存管理模块 库存管理 图书入库 图书出库 库存容量查询 结束 谢谢观看 装订线安徽工业大学 毕业设计(论文)说明书摘 要本课题搭建了皖北书城的网络管理平台,它集销售与管理于一体,共分七个模块,实现功能如下:销售管理,主要进行前台的用户管理和图书销售工作,采购管理,主要是对货物进行采集,继而对定单进行各个方式的查询,财务管理,主要是负责员工工资的发放,人员管理,主要是负责公司内部人员的考勤,工资信息计算以及基本信息的操作,客服管理,主要负责处理用户的留言工作,库存管理,主要是用于存放各类图书,进行入库和出库操作,系统管理,主要用于数据库的恢复与备份。该系统采用基于JAVA开发的WEB平台,后台数据库采用MySQL。本系统严格的按照MVC开发模式,使各个层面相互独立,便于系统的维护以及以后系统的业务修改。本文主要介绍使用JAVA语言 构建皖北书城网络管理平台的详细过程,包括可行性研究、需求分析、总体设计、详细设计、测试五个阶段。重点介绍MVC开发的具体操作方式及其设计思想。关键词:皖北书城管理系统 JAVA MVC MySQL struts hibernateABSTRACTThis thesis with practical application is concerning about developing programme of the managing system in bookshops.The computer informationization management has the storage capacity to be big,speed quick and so on many merits,provides promptly for ours process information quickly,Therefore we use the computer to provide carry on the management for ours information to online on-line purchase books, passes through carries on the appraisal after many development softwares and the database softwares superiority, finally chooses with JSP and MySQL develops a B/S structure the Northern Anhui book city management system management system.This graduation project is the application current high speed development computer technology, sets up on-line book city management system management system, is with realizes based on the JSP on-line book city management system management systems design. This system has: The onstage purchase books subsystem and the backstage manage the main system. The backstage manages the main system function to include: The personnel management procurement management online guest obeys disciplinary measures the principle, the sales management stock inquiry system administration and so on, and the contact surface simple operation is simple.Key Words Bookstore management Java,mvc,MySql,Struts,Hibernate ABSTRACT2第1章 绪论5第2章 可行性研究62.1 功能需求62.2 可行性研究72.2.1 技术可行性72.2.2 操作可行性72.3 结论8第3章 相关知识和开发工具简介83.1 Eclipse 简介83.2 MyEclipse83.3 Apache Tomcat 服务器103.4 JSP 技术概述11第4章 总体设计174.1 总体功能模块图184.2 业务流程分析204.2.1 文字描述204.2.2 业务流程图204.3功能模型分析(DFD)214.4 数据模型分析244.5人员管理系统总E-R图254.6各模块功能总体设计294.6.1 人员管理294.6.2 库存管理294.7数据库逻辑设计304.7.1 UML 设计304.8数据库设计31第5章 详细设计与实现345.1 用户登录模块的设计345.1.2 员工信息录入385.1.3 员工查询455.2 考勤管理485.2.1 考勤信息修改495.2.2 搜索考勤信息555.3库存管理:575.3.1 管理的主要页面如下:57第6章 软件测试586.1什么是软件测试596.2 软件测试的规则596.3 软件测试的对象606.4单元测试60结束语62参考文献63附录1中英文资料翻译部分65附加源代码如下:89第1章 绪论就书城系统而言,由于网络已经覆盖全球,信息量大而独具优势。售书的理念也很简单,就是读者可以自己寻找自己喜爱的书为替读者找寻他们想要的书。对于 读者来说,网上书城近在咫尺,并且永不下班关门,读者可以随时随地自由地查询和订购图书,读者无需亲临书城,一档一档地找,一本一本地翻,只要坐在电脑前,开机上网即可买到所需书籍,而且读者的挑选余地也大多了,检索也很方便,同时还减少了书城过程中的支出,另外应当看到图书选购必得翻阅详看,耗时费力,特别是热衷图书,几乎都是奋力开拓事业者和苦心求学深造者,时间对他们而言无比宝贵,网上书城节省了大量时间,这对于那些没有时间经常逛传统书城或 其住所离传统书城较远的读者来说,具有实际意义。因此网上售书必将有长足的发展。开办网上书城系统也可以为在校大学生提供方便、廉价、高效的书城方式,促进文化传播,帮助国家和学校培养优秀的人才,具有长远的社会效益和经济效益。第2章 可行性研究2.1 功能需求人员管理模块:(1)人事专员通过对新员工基本信息的录入,部门和薪资的录入。并对其修改。对辞职人员信息的删除。(2)考勤:对员工每天的工作情况进行考勤,修改,并进行薪资的统计。库存管理模块:(1)根据采购部的定单,对图书进行入库操作。(2)对库存图书查询。2.2 可行性研究可行性研究分为技术可行性研究、操作可行性研究、经济可行性研究,而本设计用于毕业设计,暂不考虑经济可行性。2.2.1 技术可行性 皖北书城管理系统,可以基于WEB平台,采用Java语言 ,数据量小,只需采用小型数据库MySql。实现过程中可以用Hibernate等连接数据库,并可以使用建立专门的实体类与数据库的相应表进行映射,通过对实体类的业务实现来控制数据库的表,从而实现了数据库的增加、删除、插入等操作,功能实现不复杂。已经学习过数据库、软件工程等相关课程,而语言基本思想大致是一样的,Java掌握起来应该没有问题。再者,网上信息特别丰富,可以上网查找有关资料,在技术方面有指导老师可以进行指导,还可以上网查询相关资料。皖北书城管理系统实现的理论及技术已经日趋成熟。因此,在技术方面实现本系统是不存在问题的。2.2.2 操作可行性本人力皖北书城管理系统的开发环境为Linux,投入Windows环境中使用,开发语言为Java(Eclipse+MyEclipse插件),后台数据库用MySql来实现,系统采用B/S模式,用户只需了解Windows基本操作就可以很好地使用本系统。因此,在操作的可行性上不存在任何问题。2.3 结论由技术可行性、操作可行性的研究,可以得出结论,皖北书城管理系统的个子系统开发是完全可行的。第3章 相关知识和开发工具简介3.1 Eclipse 简介Eclipse 是一个开放源代码的、基于 Java 的可扩展开发平台。就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境。幸运的是,Eclipse 附带了一个标准的插件集,包括 Java 开发工具(Java Development Tools,JDT)。 Eclipse 还包括插件开发环境(Plug-in Development Environment,PDE),这个组件主要针对希望扩展 Eclipse 的软件开发人员,因为它允许他们构建与 Eclipse 环境无缝集成的工具。3.2 MyEclipseMyEclipse企业级工作平台(MyEclipse Enterprise Workbench ,简称MyEclipse)是对Eclipse IDE的扩展,利用它我们可以在数据库和J2EE的开发、发布,以及应用程序服务器的整合方面极大的提高工作效率。它是功能丰富的J2EE集成开发环境,包括了完备的编码、调试、测试和发布功能,完整支持HTML, Struts, JSF, CSS, Javascript, SQL, Hibernate。在结构上,MyEclipse的特征可以被分为7类:1. J2EE模型2. WEB开发工具3. EJB开发工具4. 应用程序服务器的连接器5. J2EE项目部署服务6. 数据库服务7. MyEclipse整合帮助对于以上每一种功能上的类别,在Eclipse中都有相应的功能部件,并通过一系列的插件来实现它们。MyEclipse结构上的这种模块化,可以让我们在不影响其他模块的情况下,对任一模块进行单独的扩展和升级。简单而言,MyEclipse是Eclipse的插件,也是一款功能强大的J2EE集成开发环境,支持代码编写、配置、测试以及除错。3.3 Apache Tomcat 服务器Tomcat是Apache 软件基金会(Apache Software Foundation)的Jakarta 项目中的一个核心项目,由Apache、Sun 和其他一些公司及个人共同开发而成。由于有了Sun 的参与和支持,最新的Servlet 和JSP 规范总是能在Tomcat 中得到体现,Tomcat 5 支持最新的Servlet 2.4 和JSP 2.0 规范。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java 爱好者的喜爱并得到了部分软件开发商的认可,成为目前比较流行的Web 应用服务器。Tomcat 很受广大程序员的喜欢,因为它运行时占用的系统资源小,扩展性好,支持负载平衡与邮件服务等开发应用系统常用的功能;而且它还在不断的改进和完善中,任何一个感兴趣的程序员都可以更改它或在其中加入新的功能。Tomcat 是一个小型的轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。对于一个初学者来说,可以这样认为,当在一台机器上配置好Apache 服务器,可利用它响应对HTML 页面的访问请求。实际上Tomcat 部分是Apache 服务器的扩展,但它是独立运行的,所以当你运行tomcat 时,它实际上作为一个与Apache 独立的进程单独运行的。 这里的诀窍是,当配置正确时,Apache 为HTML页面服务,而Tomcat 实际上运行JSP 页面和Servlet。另外,Tomcat和IIS、Apache等Web服务器一样,具有处理HTML页面的功能,另外它还是一个Servlet和JSP容器,独立的Servlet容器是Tomcat的默认模式。不过,Tomcat处理静态HTML的能力不如Apache服务器。3.4 JSP 技术概述JSP(JavaServer Pages)是由Sun Microsystems公司倡导、许多公司参与一起建立的一种动态网页技术标准。JSP技术有点类似ASP技术,它是在传统的网页HTML文件(*.htm,*.html)中插入Java程序段(Scriptlet)和JSP标记(tag),从而形成JSP文件(*.jsp)。 用JSP开发的Web应用是跨平台的,即能在Linux下运行,也能在其他操作系统上运行。JSP技术使用Java编程语言编写类XML的tags和scriptlets,来封装产生动态网页的处理逻辑。网页还能通过tags和scriptlets访问存在于服务端的资源的应用逻辑。JSP将网页逻辑与网页设计和显示分离,支持可重用的基于组件的设计,使基于Web的应用程序的开发变得迅速和容易。 Web服务器在遇到访问JSP网页的请求时,首先执行其中的程序段,然后将执行结果连同JSP文件中的HTML代码一起返回给客户。插入的Java程序段可以操作数据库、重新定向网页等,以实现建立动态网页所需要的功能。 JSP与Java Servlet一样,是在服务器端执行的,通常返回该客户端的就是一个HTML文本,因此客户端只要有浏览器就能浏览。 JSP的1.0规范的最后版本是1999年9月推出的,12月又推出了1.1规范。目前较新的是JSP1.2规范,JSP2.0规范的征求意见稿也已出台。JSP页面由HTML代码和嵌入其中的Java代码所组成。服务器在页面被客户端请求以后对这些Java代码进行处理,然后将生成的HTML页面返回给客户端的浏览器。Java Servlet 是JSP的技术基础,而且大型的Web应用程序的开发需要Java Servlet和JSP配合才能完成。JSP具备了Java技术的简单易用,完全的面向对象,具有平台无关性且安全可靠,主要面向因特网的所有特点。3.5 Struts 技术Struts最早是作为Apache Jakarta项目的组成部分问世运作。项目的创立者希望通过对该项目的研究,改进和提高Java Server Pages、Servlet、标签库以及面向对象的技术水准。Struts跟Tomcat、Turbine等诸多Apache项目一样,是开源软件,这是它的一大优点,使开发者能更深入的了解其内部实现机制。MVC即Model-View-Controller的缩写,是一种常用的设计模式。MVC 减弱了业务逻辑接口和数据接口之间的耦合,以及让视图层更富于变化。Struts 是MVC的一种实现,它将 Servlet和 JSP 标记(属于 J2EE 规范)用作实现的一部分。Struts继承了MVC的各项特性,并根据J2EE的特点,做了相应的变化与扩展。struts框架具有组件的模块化,灵活性和重用性的优点,同时简化了基于MVC的web应用程序的开发。3.6 Hibernate技术Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库。 Hibernate可以应用在任何使用JDBC的场合,既可以在Java的客户端程序使用,也可以在Servlet/JSP的Web应用中使用,最具革命意义的是,Hibernate可以在应用EJB的J2EE架构中取代CMP,完成数据持久化的重任。Hibernate的核心接口一共有5个,分别为:Session、SessionFactory、Transaction、Query和Configuration。这5个核心接口在任何开发中都会用到。通过这些接口,不仅可以对持久化对象进行存取,还能够进行事务控制。下面对这五的核心接口分别加以介绍。Session接口:Session接口负责执行被持久化对象的CRUD操作(CRUD的任务是完成与数据库的交流,包含了很多常见的SQL语句。)。但需要注意的是Session对象是非线程安全的。同时,Hibernate的session不同于JSP应用中的HttpSession。这里当使用session这个术语时,其实指的是Hibernate中的session,而以后会将HttpSesion对象称为用户session。SessionFactory接口:SessionFactroy接口负责初始化Hibernate。它充当数据存储源的代理,并负责创建Session对象。这里用到了工厂模式。需要注意的是SessionFactory并不是轻量级的,因为一般情况下,一个项目通常只需要一个SessionFactory就够,当需要操作多个数据库时,可以为每个数据库指定一个SessionFactory。Configuration接口:Configuration接口负责配置并启动Hibernate,创建SessionFactory对象。在Hibernate的启动的过程中,Configuration类的实例首先定位映射文档位置、读取配置,然后创建SessionFactory对象。Transaction接口:Transaction接口负责事务相关的操作。它是可选的,可发人员也可以设计编写自己的底层事务处理代码。Query和Criteria接口:Query和Criteria接口负责执行各种数据库查询。它可以使用HQL语言或SQL语句两种表达方式。3.7 MVC的架构思想MVC(Model View Control)模型视图控制器MVC与模板概念的理解MVC本来是存在于Desktop程序中的,M是指数据模型,V是指用户界面,C则是控制器。使用MVC的目的是将M和V的实现代码分离,从而使同一个程序可以使用不同的表现形式。比如一批统计数据你可以分别用柱状图、饼图来表示。C存在的目的则是确保M和V的同步,一旦M改变,V应该同步更新。 模型视图控制器(MVC)是Xerox PARC在八十年代为编程语言Smalltalk80发明的一种软件设计模式,至今已被广泛使用。最近几年被推荐为Sun公司J2EE平台的设计模式,并且受到越来越多的使用 ColdFusion 和 PHP 的开发者的欢迎。模型视图控制器模式是一个有用的工具箱,它有很多好处,但也有一些缺点。 MVC如何工作MVC是一个设计模式,它强制性的使应用程序的输入、处理和输出分开。使用MVC应用程序被分成三个核心部件:模型、视图、控制器。它们各自处理自己的任务。 视图 视图是用户看到并与之交互的界面。对老式的Web应用程序来说,视图就是由HTML元素组成的界面,在新式的Web应用程序中,HTML依旧在视图中扮演着重要的角色,但一些新的技术已层出不穷,它们包括Macromedia Flash和象XHTML,XML/XSL,WML等一些标识语言和Web services. 如何处理应用程序的界面变得越来越有挑战性。MVC一个大的好处是它能为你的应用程序处理很多不同的视图。在视图中其实没有真正的处理发生,不管这些数据是联机存储的还是一个雇员列表,作为视图来讲,它只是作为一种输出数据并允许用户操纵的方式。 模型 模型表示企业数据和业务规则。在MVC的三个部件中,模型拥有最多的处理任务。例如它可能用象EJBs和ColdFusion Components这样的构件对象来处理数据库。被模型返回的数据是中立的,就是说模型与数据格式无关,这样一个模型能为多个视图提供数据。由于应用于模型的代码只需写一次就可以被多个视图重用,所以减少了代码的重复性。 控制器 控制器接受用户的输入并调用模型和视图去完成用户的需求。所以当单击Web页面中的超链接和发送HTML表单时,控制器本身不输出任何东西和做任何处理。它只是接收请求并决定调用哪个模型构件去处理请求,然后用确定用哪个视图来显示模型处理返回的数据。 现在我们总结MVC的处理过程,首先控制器接收用户的请求,并决定应该调用哪个模型来进行处理,然后模型用业务逻辑来处理用户的请求并返回数据,最后控制器用相应的视图格式化模型返回的数据,并通过表示层呈现给用户。开发方式Java开发Web Application有几种符合MVC设计模式的开发方式。 1:Jsp+Servlet+JavaBean(EJB) 2:Jsp+JavaBean(Controller)+JavaBean(EJB)(Model) 3:TDK(Turbine,Velocity.)4:Xsp 5:Jsp+Struts+JavaBean(EJB)第4章 总体设计经过需求分析阶段的工作,系统必须“做什么”已经清楚了,现在是决定“怎样做”的时候。总体设计的基本目的就是回答“从总体上说,系统应该如何实现?”这个问题,因此,总体设计又称为概要设计或初步设计。通过这个阶段的工作将划分出组成系统的物理元素程序、文件、数据库、人工过程和文档等等,但是每个物理元素仍然处于黑盒子级,这些黑盒子里的具体内容将在以后进行详细的设计。总体设计阶段的另一项重要任务是设计软件的结构,也就是要确定系统中每个程序是由哪些模块组成的,以及这些模块相互间的关系。总体设计是软件设计阶段的第一步,在软件开发时期中,设计阶段是最富有活力,最需要发挥创造精神的阶段。在本阶段,主要就是得用面向对象分析方法把分析阶段产生的软件需求说明转换为用适当手段表示的软件概要设计文档,从而得出本模块的具体实现方案与总体结构以及各组成部分之间的关系。4.1 总体功能模块图系统功能模块图如图5-1:皖北书城管理系统人员管理模块库存管理模块采购管理模块客服管理模块销售管理模块系统管理模块人员员模块用于对公司员工信息统一管理,包含的功能如图所示。人员管理员员工信息管理员工考勤库存管理用于管理和查询仓库的相关信息,包含的功能模块如图所示。库存管理入库出库库存信息查询4.2 业务流程分析4.2.1 文字描述 开发这个模块的目的就是帮助企业的人力资源部门提高工作效率,实现企业人员信息管理的系统化,规范化和自动话。根据这个系统最终实现的主要功能如下:*员工基本信息部分:主要完成员工基本信息的管理。*员工考勤信息部分:主要完成员工考勤信息的管理。*员工调动信息部分:主要完成员工调动信息的管理.库存管理的主要业务流程:根据采购定单,销售定单,对图书进行入库和出库操作。对仓库信息的查询。4.2.2 业务流程图如图:添加新员工加入部门 人事专员员工信息修改员工考勤薪资统计员工考勤信息修改4.3功能模型分析(DFD)绘制数据流图的基本要求:系统的顶层图使用来表示整个系统的功能结构。随着需求分析活动的逐渐深入,较高抽象级别上的复杂转换可以精化为一系列的相互关联的数据流和子转换。数据流图描述系统的逻辑模型,在设计数据流图只需考虑系统必须完成的基本逻辑功能,完全不需要考虑如何具体的实现这些,该系统的数据流程图可确定如下:管理事务 人员管理人事管理事务回应图4-2数据流图顶层图系统一层图如图4-3所示: 人事专员人员管理员工信息员工信息系统设置管理员及系统信息系统信息考勤管理考勤信息等考勤信息系统二层图如图4-4至图4-8所示:人事专员1.1人员添加1.2人员修改1.3人员删除人员信息图4-4数据流图二层图处理2 库存管理细化如图4-5管理员采购定单销售定单库存采购信息销售信息仓库信息图4-5数据流图二层图4.4 数据模型分析概念结构的主要特点:能真实的、充分的反映现实世界,包括事物和事物之间的联系,能够满足用户对数据的处理要求。是对现实世界的一个真实模型。易于理解,从而可以用它和不熟悉计算机的用户交换意见,用户积极参与是数据库设计成功的关键。易于更改,当应用环境和应用要求改变时,容易对概念模型进行修改和扩充。易于向关系、层次、网状等各种数据模型转化。描述概念的有力工具是E-R图,下面将对本系统的数据库进行概念设计,并画出E-R图。图例:实体: 关系: 属性:4.5人员管理系统总E-R图根据系统需求及ER模型的基本属性,可以分析出人力资源管理系统的实体联系模型(ER模型)。如图4-9所示:salarryN1N1NjobattendancesN1M1diplomadeptPerson工资制度对应对应2对应3对应1NM拥有对应1polity对应3N1user对应31图4-9系统总E-R图员工实体如图4-10:ID_cardemailsalaryjobdeptpolitybankdiplomauserattendacePersonemploye_nogemderbirthdaymarrynpaddresstelmobilename图4-10 用户实体E-R图ProductprinterisbnnameauthornamecreateDateorderncatalogbooknumprice库存实体如图4-11:description图4-11 网络实体E-R图定单实体如图4-12datebusinessTypeBusiness_orderbusinessTypeproducts4.6各模块功能总体设计4.6.1 人员管理1:信息录入:当公司招聘了新员工,需要对员工进行管理,就要录入员工的基本信息,还有分配哪个部门。其基本工资录入,以便之后对其每月工资的统计。2:信息修改:当员工信息有所变动的时候需要对其基本信息的修改,还有员工的调动,也要对其部门的修改。3:信息删除:当员工辞职和退休后,需要对其信息进行删除。4:(1)添加考勤信息:主要分为上下班信息和其他考勤信息。上下班信息要记录每个员工每天上下班的时间,而其他考勤信息包括含有请假,加班,出差信息。(2)修改考勤信息:当考勤信息出现错误需要修改的时候,可以从这里修改相应的记录。(3)查询考勤信息:根据员工编号或者时间进行查询,得到所有的考勤信息,包括上下班,请假,加班和出差信息,但是不能够对信息进行任何操作。(4)删除考勤信息:分为删除上下班信息和删除其他考勤信息。4.6.2 库存管理1:库存也是一个企业管理的一个重要的部分,其功能有,出入库管理和仓库信息查询,及时警告库存不足,通过有库存信息能够统计哪些在这个时期阶段的销售好坏。4.7数据库逻辑设计4.7.1 UML 设计4.8数据库设计根据系统功能设计的要求以及功能模块的划分,对于本系统的数据库,可以列出以下数据项和数据结构:员工表:员工政治面貌表h_polity_info:员工职位表h_job_info:员工学历表 h_diploma_info:部门表 h_dept_info:银行表h_bank_info:考勤信息表 - h_attendance_info:用户表 - h_user_info: 用户类型表 h_usreTye_info:图书表 h_product_info:定单表:第5章 详细设计与实现5.1 用户登录模块的设计用户登陆皖北书城后台管理,可以根据其所在部门执行相关的管理操作。用户登录信息流程图C层开 始检验是否正确返回错误页面输入用户名和密码是否存在DAO 登录失败NYN 持久层 M层 V层JSP页面部分主要的界面如下: 表现层(V层)用户可以用自己已经注册过的帐号进行登录。 控制层 (C层)结合上图,处理步骤:从页面发送的请求中获取登录条件对用户输入的登录帐号和密码作为字符串进行解析,如果格式不正确之后,直接返回错误页面,让用户重新输入帐号和密码。通过验证后,将用户输入的帐号信息包装成一个用户对象然后通过通过判断用户对象是否为空调用业务方法进行查询用户,如果对象不为空,则表示登录成功。相关代码:public ActionForward login(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionLoginForm loginForm=(LoginForm) form;User user=new User(); user.setUser_name(loginForm.getUsername();user.setUser_password(loginForm.getUserpassword(); UserService service=new UserServiceImpl();try User u = service.select(user);System.out.println(u);if(u!=null)HttpSession session = request.getSession();session.setAttribute(u,u );return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);return mapping.findForward(login);5.1.2 员工信息录入人事专员点击添加员工,详细操作如下:人事专员点击添加员工提取信息是否填写信息是否通过验 证过滤掉YNNYDAO V层 C层 M层 持久层 JSP页面主要界面如下: 表现层(V层)用户可以根据自己的输入信息进行注册 控制层 (C层)结合上图,处理步骤:从页面发送的请求中获取输入信息对用户输入的登录帐号和密码和各项信息作为字符串进行解析,如果格式不正确之后,直接返回错误页面,让用户重新输入信息进行注册。通过验证后,将用户输入的帐号信息包装成一个用户对象然后通过通过判断用户对象是否为空调用业务查询方法进行查询用户,如果对象不为空,则表示是已经注册用户,需重新注册,如果为空,则为这个用户新生成一个对象,持久化到数据库中。相关代码:public ActionForward addPerson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionPerson person=new Person();Diploma dip=new Diploma();Bank bank=new Bank();Polity polity=new Polity();User user=new User();UserType userType=new UserType();Job job=new Job();Dept d=new Dept();String employe_no=request.getParameter(person_no);String name=request.getParameter(name);String gender = request.getParameter(gender);String birthday = request.getParameter(birthday);String marry = request.getParameter(marry);String np = request.getParameter(np);String address = request.getParameter(address);String email = request.getParameter(email);Long tel = Long.parseLong(request.getParameter(tel);Long mobile = Long.parseLong(request.getParameter(mobile);Long ID_card = Long.parseLong(request.getParameter(ID_card);String dept=request.getParameter(dept);String diploma_name=request.getParameter(diploma);String job_name=request.getParameter(job);String p=request.getParameter(polity);String b=request.getParameter(bank);dip.setDiploma_name(diploma_name);userType.setUserType_name(dept);user.setUser_name(employe_no);user.setUser_password(employe_no);job.setName(job_name);d.setName(dept);person.setEmploye_no(employe_no);person.setName(name);person.setGender(gender);person.setBirthday(birthday);person.setMarry(marry);person.setNp(np);person.setAddress(address);person.setEmail(email);person.setTel(tel);person.setMobile(mobile);person.setID_card(ID_card);/dip.addPersons(person);/user.setUser_type(userType);user.setPerson(person);/job.addPerson(person);/polity.setName(p);/bank.setName(b);/PersonService service=new PersonServiceImpl();DeptService deptService=new DeptServiceImpl();try Dept d1=deptService.selectDept(d);if(d1=null)deptService.save(d);d.addPerson(person);elsed1.addPerson(person);service.addPerson(person);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);5.1.3 员工查询主要界面如下:相关代码如下:public ActionForward selectPerson(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionPerson person = new Person();Dept dept=new Dept();String selectid=request.getParameter(selectid);String selectKey=request.getParameter(selectKey);PersonService service=new PersonServiceImpl();List list=new ArrayList();DeptService deptService=new DeptServiceImpl();try if(selectKey.equals(name)person.setName(selectid);Person p=service.selectPerson(person);list.add(p);else if(selectKey.equals(no)person.setEmploye_no(selectid);Person p=service.selectPerson(person);list.add(p);else if(selectKey.equals(deptName)dept.setName(selectid);list=deptService.selectByDept(dept);if(list!=null)request.setAttribute(list,list);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(errror);return mapping.findForward(select);5.1.4 员工信息修改5.2 考勤管理考勤主要界面如下:5.2.1 考勤信息修改界面如下: 相关代码如下:public static List list = new ArrayList();public ActionForward select(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionDept dept=new Dept();String deptName=request.getParameter(selectid);dept.setName(deptName);DeptService service=new DeptServiceImpl();try list = service.selectByDept(dept);request.setAttribute(list, list);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);public ActionForward add(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionPerson person=new Person();Attendance attendance=new Attendance();String employe_no=request.getParameter(employe_no);String str1=request.getParameter(year);String str2=request.getParameter(month);String str3=request.getParameter(day);String str=str1+-+str2+-+str3;int no=Integer.parseInt(request.getParameter(work_information);attendance.setAttendance_date(str);attendance.setNo(no);person.setEmploye_no(employe_no);PersonService pServie=new PersonServiceImpl();AttendanceService service=new AttendanceServiceImpl();try Person p=pServie.selectPerson(person);p.addAttendance(attendance);service.add(attendance);Iterator it=list.iterator();while(it.hasNext()Person p1=(Person)it.next();System.out.println();if(p1.getEmploye_no().equals(p.getEmploye_no()list.remove(p1);request.setAttribute(list, list);break;return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);public ActionForward selectByNo(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionPerson person=new Person();String str1=request.getParameter(year);String str2=request.getParameter(month);String str=str1+-+str2;String employe_no=request.getParameter(selectid);person.setEmploye_no(employe_no);AttendanceService aservice=new AttendanceServiceImpl();PersonService pservice=new PersonServiceImpl();try Person p=pservice.selectPerson(person);List list=aservice.select(p, str);request.setAttribute(list, list);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionPerson person=new Person();Attendance attendance=new Attendance();String employe_no=request.getParameter(employe_no);String date=request.getParameter(attendance_date);int no=Integer.parseInt(request.getParameter(work_information);person.setEmploye_no(employe_no);attendance.setAttendance_date(date);attendance.setNo(no);PersonService ps=new PersonServiceImpl();AttendanceService service=new AttendanceServiceImpl();try Person p=ps.selectPerson(person);service.update(p, attendance);ps.updatePerson(p);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);5.2.2 搜索考勤信息相关代码:public ActionForward select(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ExceptionDept dept=new Dept();String deptName=request.getParameter(selectid);dept.setName(deptName);DeptService service=new DeptServiceImpl();try list = service.selectByDept(dept);request.setAttribute(list, list);return mapping.findForward(success); catch (Exception e) e.printStackTrace();return mapping.findForward(error);5.3库存管理:5.3.1 管理的主要页面如下:添加图书到定单的页面如下:第6章 软件测试在开发软件的过程中,人们使用了许多保证软件质量的方法分析、设计和实现软件,但难免还会在工在软作中犯错误。这样,件产品中就会隐藏许多错误和缺陷,尤其是对规模大、复杂性高的软件更是如此。所以,必须进行认真、计划、彻底的软件测试。6.1什么是软件测试软件测试就是在软件投入运行前,对软件需求分析、设计规格说明书和编码的最终复审,是软件质量保证的关键步骤。确切的说,软件测试就是为了发现错误而执行的过程。一般分为两个阶段:(1)单元测试:在编完某一模块后进行测试(2)综合测试:在开发完软件后进行系统测试。即使经过最严格的测试之后,仍然可能还有没被发现的错误隐藏在程序中。测试只能查找程序中的错误,不能证明程序中没有错误。6.2 软件测试的规则软件测试的目的是想以最少的时间和人力找出软件中潜在的错误和缺陷。一个成功的软件应该不怕挑剔的用户进行测试。如果成功的实施了测试,就能够发现软件存在的错误。根据这样的测试目的,软件测试的规则应该是:1.应该把“尽早地和不断地进行软件测试”作为软件开发者的座右铭。2.测试用例应由测试输入数据和与之对应的预期输出结果两部分组成。3.程序员应避免检查自己的程序。4.在设计测试用例时,应当包括合理的输入条件和不合理的输入条件。5.充分注意测试中的群集现象。6.严格执行测试计划,排除测试的随意性。7.应当对每一个测试结果做全面检查。8.妥善保存测试计划,测试用例,出错统计和最终分析报告。6.3 软件测试的对象软件测试不等于程序测试。软件测试应贯穿于软件定义与开发的整个周期。所以,需求分析、概要设计、详细设计以及程序编码等各阶段所得到的文档都应该是软件测试的对象。6.4单元测试本程序的测试在Windows XP环境下进行。登录部分测试如图6-1表6-1登录测试用例等价类划分测试数据预期结果实测结果用户名密码合理等价类数据库中存在用户密码正确R001123456登录成功登录成功不合理等价类数据库中密码不符R001111登录不成功登录不成功用户名为空用户名不能为空用户名不能为空6.4.2 添加员工部分测试实例图等价类划分测试数据预期结果实测结果密码邮箱合理等价类数据库中存在用户密码正确123456789Yain9598注册成功注册成功不合理等价类数据库中密码不符123Yain9598注册不成功注册不成功用户名为空密码不能为空密码不能为空结束语本设计在陆勤老师和战老师的悉心指导和严格要求下业已完成,从课题选择、方案论证到具体设计和调试,无不凝聚着两位老师的心血和汗水,在学习期间始终感受着导师的精心指导和无私的关怀,我受益匪浅。在此向两位老师表示深深的感谢和崇高的敬意。 不积跬步何以至千里,本设计能够顺利的完成,也归功于各位任课老师的认真负责,使我能够很好的掌握和运用专业知识,并在设计中得以体现。正是有了他们的悉心帮助和支持,才使我的毕业论文工作顺利完成,在此向安徽工业大学,计算机学院的全体老师表示由衷的谢意。感谢他们四年来的辛勤栽培。 通过对皖北书城管理系统的设计与开发,不仅对以前所学的内容也很好巩固,如:数据库,数据结构,软件工程等等,还学习了新的知识,java、JDBC、Hibernae、Servlet、Struts等等,在这期间,我学到了很多知识也有很多感受,写代码肯定回有bug,所以要学会调bug,每调出一个bug就有一份收获,努力和同组人沟通,查看相关的资料和书籍,使自己非常稚嫩作品一步步完善起来,每一次改进都是我学习的收获,每一次bug的调试成功都会让我兴奋好一段时间。虽然我的论文作品不是很成熟,还有很多不足之处,但我可以自豪的说,这里面的每一段代码,都有我的劳动。当看着自己的程序,自己成天相伴的系统能够健康的运行,真是莫大的幸福和欣慰。我相信其中的酸甜苦辣最终都会化为甜美的甘泉。该系统是由邢阿亮,陶金,和我,共同完成的。通过对皖北书城管理系统的设计和开发,锻炼了我的实际动手能力,和团队合作精神,我谢谢他们,这次做论文的经历也会使我终身受益,我感受到做论文是要真真正正用心去做的一件事情,是真正的自己学习的过程和研究的过程,没有学习就不可能有研究的能力,没有自己的研究,就不会有所突破,那也就不叫论文了。希望这次的经历能让我在以后学习中激励我继续进步。 参考文献1.Java 面向对象编程 孙卫琴 电子工业出版社2007.92.Eclipse 从入门到精通 陈刚 清华大学出版社 2005.63.精通Tomcat刘中兵 许晓昕 薛道铭 清华大学出版社 2007.54深入浅出Hibernate曹晓刚 编著 电子工业出版社 2005.65. JDBC & HTML & JavaScript 达内科技公司6. XML & Hibernate 达内科技公司7.Eclipse SWT/JFace 开发实战精解王津涛 孟庆昌 人民邮电出版社 2007.6 8.Jsp动态网站技术的入门与提高 孙晓龙编著 人民邮电出版社 2001.79.JAVA 安全性编程指南Jess Garms 编著 电子工业出版社 2002.110.Java案例开发集锦郑自国 编著 电子工业出版社 2005.9附录1中英文资料翻译部分Hibernate technologyWhat is hibernate:History and backgroundThe majority application procedures need to process the data. When Java application program run, often data encapsulation for interconnection object network, but when the procedure ended, these objects will vanish in a group logic, therefore needed to have some to preserve their method. Even sometimes, before compilation application procedure, the data already had existed, therefore needs to have reads in them and its expression for the object method. The manual compilation code carries out these tasks not only monotonously tasteless, easy to make a mistake, will take the entire application procedure the very big part of development work load.The outstanding object-oriented development personnel have been weary of this kind of duplicated work, they start usually to use “positive” are loaf make the law, namely, founds the tool, causes the entire process automation. Regarding the relational database, this kind of biggest achievement diligently is the object/relations maps the (ORM) tool.This kind of tool has many, from expensive commercial product to built-in J2EE EJB standard. However, in many situations, these tools has own complexity, causes the development personnel to study uses their detailed rules, and revises the composition application procedure the kind to meet the mapping systems needs. Because these tools to deal with stricter and the complex enterprise demand, but develops unceasingly, therefore in quite simple and common scene, uses complexity instead Ge Guo who they face the advantage which can obtain. This has caused a revolution, promoted the lightweight solution appearance, but Hibernate is a such example.Hibernate workingHibernate will not create the hindrance to you, also will not force you to revise the object the behavior way. They do not need to realize any inconceivable connection in order to exist continually. Only needs to do is founds XML “the mapping documents”, tells Hibernate you to hope that can preserve in the database the kind, as well as how are they connected in this database the table and the row, then may request it by the object form gain data, or the object preservation is the data. Compares with other solution, it was very nearly already perfect.Because this article is only an introductive article, will therefore not introduce constructs and uses Hibernate to map the documents the concrete example (I in Hibernate: A Developers Notebook in a books first several chapter already introduced an example). In addition, on-line with in Hibernate online documents, but might also find some good examples, please see also following “other information” the part. It is quite in fact direct-viewing. In the application procedure objects attribute simple and the natural way and the correct database structure is connected by one kind.When movement, the Hibernate read mapping documents, then dynamic construct the Java kind, with the aim of managing between the database and the Java transformation. Has one in Hibernate simple and direct-viewing API, uses in object execution inquiry which expressed to the database. Must revise these objects, (in ordinary circumstances) only need carry on the procedure with them alternately, then tells the Hibernate preservation revision then. , Founds the new object to be very also simple similarly; Only need found them by the conventional way, then tells Hibernate to concern their information, like this can preserve them in the database.Hibernate API studies is very simple, moreover it and procedure class alternately suitable nature. Transfers it in the suitable position, may achieve the goal. It has brought many automations and the code saves the aspect the advantage, therefore spends time to learn from it to be worth. Moreover may also obtain another advantage, namely the code does not need the database type which the care must use (otherwise even to know). I am at the company once had later period has been compelled in the performance history to replace the database manufacturer the experience. This will create the huge disaster, but with the aid in Hibernate, will only need to revise the Hibernate configuration files simply then.Here discussion supposed you already through to found the Hibernate mapping documents, has established a relational database, and had the Java kind which must map. Some Hibernate “the tool collection” may when the translation uses, supports the different work class. For example, if you already had Java kind and the mapping documents, Hibernate may found (or renewal) for you the essential database table. Or, starts merely from the mapping documents, Hibernate can also the generated data class. Or, it may design your database and the kind reverse, thus draws up the mapping documents. Also has some to use in Eclipse the alpha plug-in unit, they may provide intelligent in IDE the edition support as well as visit to these tools graph.What if you use is Hibernate 2 environment, these tools rarely have provide, but has the available third party tool.Uses Hibernate the situationSince Hibernate looks like so nimbly easy to use, why can also use other tools? Below has some scenes, (perhaps may help you to make the judgment through to provide some comparisons and context, may be helpful to the distinction very suitable Hibernate situation).If applies regarding the data storage need is very simple - - for example, you only want to manage group of user priority selection - - you simply not to need the database, say nothing of an outstanding object - relations mapping systematic (, even if its also like Hibernate easier use)! From the Java 1.4 starts, some standard Java Preferences API may play this role well. (might find related Preferences API in the ONJava article more information. )Regarding the familiar use relational database and understood how to carry out the perfect SQL inquiry with the enterprise database interactive person, Hibernate as if somewhat was in the way, this likely had the vehicle race pilot who the power and automatic gears speed boat Che Huishi paid great attention the performance to be impatiently same. If you belong to this kind of person, if you are at the project team has formidable DBA, or has some memory process to process, you possibly want to study iBATIS. The Hibernate founder himself treats as iBATIS is another kind of interesting choice. I have the interest very much to it, because we once were an electronic commerce stand develop a similar system (its function to be more formidable), moreover from to the present, we already had used at that time it in other environment, although after discovering Hibernate, in the new project we usually likes using Hibernate. You may believe that take SQL as the central solution (for instance iBATIS) is “reverse” the object/relations mapping tool, but Hibernate is traditional ORM.Certainly, will also have other external reason to cause to use other method. For instance, in an enterprise environment, must use the mature EJB construction (or other non-ordinary objects maps system). May to provide own data storage tools platform quantity body custom make code, for instance Mac OS Xs Core Data. The use possibly is looks like XML the DTD such memory standard, but it simply does not involve the relational database.But, what if you use is the rich object model, moreover wants nimbly, with ease and preserves it highly effective (, regardless of you whether to be just about to starts or already decided use relational database, so long as this were a choice - - and has available outstanding free database, for instance MySQL, or might insert Java HSQLDB, it should be throughout a choice), then Hibernate was very possible is your ideal choice. You possibly surprised many in economical time, as well as you will like using it.Hibernate meritFirst, Hibernate is the JDBC lightweight object seal, it is an independent object lasting level frame, with App Server, with the EJB not anything inevitable relation. Hibernate may use the situation which may use in any JDBC, for example the Java application procedures database visit code, the DAO connection realizes the kind, even may be inside the BMP visit database code. In this sense, Hibernate and EB are not a category thing, also does not have either this or thats relations.Second, Hibernate is one with the JDBC close connection frame, therefore the Hibernate compatibility and the JDBC actuation, have certain relations with the database, but with uses its Java procedure, with App Server not any relations, also does not have the compatible problem.Third, Hibernate cannot use for to make the contrast directly with Entity Bean, only then places the entire J2EE project in the frame to be able the comparison. Even if and is places in the software overall frame, Hibernate is also does is the JDBC replacer appears, but is not the Entity Bean replacer appears, let me arrange in order time me already to arrange in order n time again portal frame construction:Traditional construction: 1) Session Bean Entity Bean DB to solve the performance barrier substitution construction: 2) Session Bean DAO JDBC DB uses Hibernate to enhance the above construction the development efficiency construction: 3) Session Bean DAO Hibernate DBAnalyzes on the above 3 constructions:1st, the memory consumes to use JDBC the construction 2 is without doubt most saves the memory, Hibernate construction 3 next bests, EB construction 1 worst. 2, operating efficiency , if the JDBC code writes unusual optimization, then the JDBC construction operating efficiency is highest, but in the actual project, this point cannot achieve nearly, this need programmer is skilled in JDBC, utilizes the Batch sentence, adjusts PreapredStatement Batch Size and parameters and so on Fetch Size, as well as in the essential situation uses result collection cache and so on. But in the ordinary circumstances the programmer cannot achieve this point. Therefore the Hibernate construction displays the quickest operating efficiency. The EB construction efficiency can miss is very far.3rd, development efficiency in has under the JBuilder support as well as the simple project, the EB construction development efficiency is highest, the JDBC next best, Hibernate is worst. But in big project, specially in lasting level relations mapping very complex situation, Hibernate efficiency high astonishment, JDBC next best, but the EB construction will possibly be defeated. 4, distributional, security check, colony, load equalization support , because has SB to do is a Facade,3 construction has not distinguished.Fourth, EB and Hibernate study difficulty in where?EB difficulty in where? Not in complex XML configuration files, but lies in the EB utilization slightly carelessly, has the serious performance barrier. Therefore needs to study many EJB design pattern difficultly in you to avoid the performance question, needs to study App Server and the EB disposition optimizes EB the operating efficiency. Made EB the development work, programmers majority of energy is put in the EB performance question, instead did not have more energy attention itself mainly to put into the object lasting level design which the energy considered.Hibernate difficultly in where? In Hibernate complex, in fact the Hibernate unusual simplicity, difficultly was too not nimble in HibernateWhen you use EB realizes lasting level time, you will discover that EB was really too clumsy, simply did not have the leeway which clumsily to you anything might choose, therefore you did not use the expenditure energy design proposal, went to the balanced plan the quality, beat brains to consider that which plan chose, because only then the only plan suspended in front of you, you only could such do, do not have the choice.Hibernate is opposite, it has been too nimble, the same question, you may design several kind of plans at least to solve, therefore special worrying, actually does use this, uses that? What between these plans has to distinguish? What does their movement principle have differently? Operating efficiency which is quite good? The light is the principal linkage production, has 78 kind of plans to choose for you, are you awkward? Gathers the attribute to be possible to use Set, may use List, but may also use Bag, which efficiency is high, are you awkward? The inquiry may use iterator, may use list, which good, has what to distinguish? Are you awkward? The compound principal linkage you may dispose directly inside hbm, may also from define CustomerType, which kind compares many? Are you awkward? Regarding a table, you may choose map an object solely, may also map the fathers and sons object, but may also map two 1:1 object, what situation uses which kind of plan to be quite good, are you awkward?This tabulation may draw up, does not want to look again until you. When in front of you are suspending plan time which innumerable is dazzled, you will think happily? Sorrowful? If you are a responsible programmer, then your certainly dwell upon each kind of plan difference, each kind of plan efficiency, each kind of plan suitable situation, you will think that you already fell into cannot pull out. If with EB, your first second kind already had made the decision, does not have the choice, for example gathers the attribute, you can only use Collection, if is Hibernate, you between Bag, List and Set back and forth indecisive, will not make clear, the procedure will not have the means to write.Hibernate a jar package of function explains in detailHibernate altogether has included 23 jar packages, dazzling. This article will explain Hibernate in detail each jar package of function, is advantageous for you according to own to need to carry on the choices in the applicationDownloads Hibernate, for example 2.0.3 stable editions, solve the compression, may see that has 22 jar packges to hibernate2.jar and under the lib table of contents:hibernate2.jar the Hibernate storehouse, anything has not been possible saying that must use jar package.cglib-asm.jar the CGLIB storehouse, Hibernate realizes the PO byte code dynamic production with it, the unusual cores storehouse, must use jar package.dom4j.jar dom4j is Java XML API, is similar in jdom, uses for the read-write XML document. dom4j is very very outstanding Java XML API, has the performance to be outstanding, the function is formidable and the extreme easy to use the characteristic, simultaneously it is also an open source code software, might find it on SourceForge. Might find an article above IBM developerWorks, carried on the performance, the function to mainstream Java XML API and the usability evaluation, dom4j, regardless in that aspect were very splendid. I will be as early as near for two years ago starts to use dom4j, until now. Now you may see more and more Java softwares are using dom4j to come read-write XML, what is worth mentioning specially is links Sun JAXM also to use dom4j. This is the jar package which must use, Hibernate comes the read-write configuration files with it.odmg.jar ODMG was a ORM standard, Hibernate has realized the ODMG standard, this was a core storehouse, must use jar package. commons-collections.jar Apache Commons package, has contained some Apache development set class, the function is more formidable than java.util.*. Must use jar mons-lang.jar Apache Commons package, has contained some data type tool class, is the java.lang.* expansion. Must use jar mons-logging.jar Apache Commons package, has contained the journal function, must use jar package. This wrapped itself to contain Simple Logger, but the function was very weak. Will look for log4j first in movement time it in CLASSPATH, if will have, will use log4j, if will not have, will look for JDK1.4 belts java.util.logging, if could also not find uses Simple Logger. the commons-logging.jar appearance is a history the carry-over regret, initially Apache vigorously solicited support Sun to join log4j JDK1.4, however the JDK1.4 project group already approached issues the JDK1.4 product the time, therefore has rejected the Apache request, uses own java.util.logging, this packages function is worse than log4j is very far, the performance is also ordinary.connector.jar JCA standard, if you on App Server the Hibernate disposition are Connector, needs this jar. However in fact general App Server definitely will take to bring with this package, therefore in fact will be the unnecessary package. jaas.jar JAAS is uses for to carry on the jurisdiction confirmation, already contained inside JDK1.4. Therefore in fact is the unnecessary package. if jcs.jar you prepare in Hibernate to use JCS, then must include it, otherwise does not use.jdbc2_0-stdext.jar the JDBC2.0 expansion package, generally speaking the database connection pond will use it. However App Server can take to bring with, therefore is also unnecessary. jta.jar JTA standard, when Hibernate uses JTA time needs, but App Server can take to bring with, therefore is also unnecessary. junit.jar Junit package, when you move Hibernate bringing test code time needs, otherwise does not use. xalan.jar, xerces.jar, xml-apis.jar Xerces is the XML resolver, Xalan is the formatting, xml-apis in fact is JAXP. Generally App Server can take to bring with, JDK1.4 has also contained the resolver, but is not Xerces, is Crimson, the efficiency is quite bad, but Hibernate just reads the configuration files with XML, performance anything has not been critical, therefore is also unnecessary.Hibernate 技术何为hibernate:历史与背景大多数应用程序都需要处理数据。Java应用程序运行时,往往把数据封装为相互连接的对象网络,但是当程序结束时,这些对象就会消失在一团逻辑中,所以需要有一些保存它们的方法。有时候,甚至在编写应用程序之前,数据就已经存在了,所以需要有读入它们和将其表示为对象的方法。手动编写代码来执行这些任务不仅单调乏味、易于出错,而且会占用整个应用程序的很大一部分开发工作量。 优秀的面向对象开发人员厌倦了这种重复性的劳动,他们开始采用通常的“积极”偷懒做法,即,创建工具,使整个过程自动化。对于关系数据库来说,这种努力的最大成果就是对象/关系映射(ORM)工具。这类工具有很多,从昂贵的商业产品到内置于J2EE中的EJB标准。然而,在很多情况下,这些工具具有自身的复杂性,使得开发人员必须学习使用它们的详细规则,并修改组成应用程序的类以满足映射系统的需要。由于这些工具为应付更加严格和复杂的企业需求而不断发展,于是在比较简单和常见的场景中,使用它们所面临的复杂性反而盖过了所能获得的好处。这引起了一场革命,促进了轻量级解决方案的出现,而Hibernate就是这样的一个例子。Hibernate的工作方式 Hibernate不会对您造成妨碍,也不会强迫您修改对象的行为方式。它们不需要实现任何不可思议的接口以便能够持续存在。惟一需要做的就是创建一份XML“映射文档”,告诉Hibernate您希望能够保存在数据库中的类,以及它们如何关联到该数据库中的表和列,然后就可以要求它以对象的形式获取数据,或者把对象保存为数据。与其他解决方案相比,它几乎已经很完美了。 由于本文只是一篇介绍性的文章,所以不会引入构建和使用Hibernate映射文档的具体例子(我在Hibernate: A Developers Notebook一书的头几章中已经介绍了一个例子)。此外,在网上和Hibernate的在线文档中,还可以找到一些不错的例子,请参见下面的“其他信息”部分。它实际上相当直观。应用程序对象中的属性以一种简单而自然的方式与正确的数据库结构相关联。运行时,Hibernate读取映射文档,然后动态构建Java类,以便管理数据库与Java之间的转换。在Hibernate中有一个简单而直观的API,用于对数据库所表示的对象执行查询。要修改这些对象,(一般情况下)只需在程序中与它们进行交互,然后告诉Hibernate保存修改即可。类似地,创建新对象也很简单;只需以常规方式创建它们,然后告诉Hibernate有关它们的信息,这样就能在数据库中保存它们。Hibernate API学习起来很简单,而且它与程序流的交互相当自然。在适当的位置调用它,就可以达成目的。它带来了很多自动化和代码节省方面的好处,所以花一点时间学习它是值得的。而且还可以获得另一个好处,即代码不用关心要使用的数据库种类(否则的话甚至必须知道)。我所在的公司就曾有过在开发过程后期被迫更换数据库厂商的经历。这会造成巨大的灾难,但是借助于Hibernate,只需要简单地修改Hibernate配置文件即可。这里的讨论假定您已经通过创建Hibernate映射文档,建立了一个关系数据库,并且拥有要映射的Java类。有一个Hibernate“工具集”可在编译时使用,以支持不同的工作流。例如,如果您已经拥有Java类和映射文档,Hibernate可以为您创建(或更新)必需的数据库表。或者,仅仅从映射文档开始,Hibernate也能够生成数据类。或者,它可以反向设计您的数据库和类,从而拟定映射文档。还有一些用于Eclipse的alpha 插件,它们可以在IDE中提供智能的编辑支持以及对这些工具的图形访问。如果您使用的是Hibernate 2环境,这些工具鲜有提供,但是存在可用的第三方工具。使用Hibernate的场合既然Hibernate看起来如此灵活好用,为什么还要使用其他的工具呢?下面有一些场景,可以帮助您做出判断(或许通过提供一些比较和上下文,可以有助于鉴别非常适用Hibernate的场合)。 如果应用对于数据存储的需要十分简单例如,您只想管理一组用户优先选择您根本不需要数据库,更不用说一个优秀的对象-关系映射系统了(即使它也如Hibernate这般易于使用)!从Java 1.4开始,有一个标准的Java Preferences API可以很好地发挥这个作用。(在ONJava文章中可以找到有关Preferences API的更多信息。)对于熟悉使用关系数据库和了解如何执行完美的SQL查询与企业数据库交互的人来说,Hibernate似乎有些碍手碍脚,这就像带有动力和自动排挡的快艇车会使注重性能的赛车驾驶员不耐烦一样。如果您属于这种人,如果您所在的项目团队拥有一个强大的DBA,或者有一些存储过程要处理,您可能想研究一下iBATIS。Hibernate的创建者本身就把iBATIS当作是另一种有趣的选择。我对它很有兴趣,因为我们曾为一个电子商务站点开发了一个类似的系统(其功能更为强大),而且从那时到现在,我们已经在其他环境中使用过它,尽管在发现Hibernate之后,在新项目中我们通常更喜欢使用Hibernate。您可以认为,以SQL为中心的解决方案(比如iBATIS)是“反向的”对象/关系映射工具,而Hibernate是一个更为传统的ORM。当然,还有其他的外部原因会导致采用另外的方法。比如,在一个企业环境中,必须使用成熟的EJB架构(或者其他的一些非普通对象映射系统)。可以为提供自己的数据存储工具的平台量身定做代码,比如Mac OS Xs Core Data。使用的可能是像XML DTD这样的存储规范,而它根本不涉及关系数据库。但是,如果您使用的是富对象模型,而且想要灵活、轻松且高效地保存它(无论您是否正要开始或已经决定使用关系数据库,只要这是一个选择而且存在可用的优秀免费数据库,比如MySQL,或可嵌入Java的HSQLDB,它就应该始终是一个选择),那么Hibernate很可能就是您理想的选择。您可能会惊讶于节省的时间之多,以及您将会多么地喜欢使用它。Hibernate 优点一、Hibernate是JDBC的轻量级的对象封装,它是一个独立的对象持久层框架,和App Server,和EJB没有什么必然的联系。Hibernate可以用在任何JDBC可以使用的场合,例如Java应用程序的数据库访问代码,DAO接口的实现类,甚至可以是BMP里面的访问数据库的代码。从这个意义上来说,Hibernate和EB不是一个范畴的东西,也不存在非此即彼的关系。二、Hibernate是一个和JDBC密切关联的框架,所以Hibernate的兼容性和JDBC驱动,和数据库都有一定的关系,但是和使用它的Java程序,和App Server没有任何关系,也不存在兼容性问题。三、Hibernate不能用来直接和Entity Bean做对比,只有放在整个J2EE项目的框架中才能比较。并且即使是放在软件整体框架中来看,Hibernate也是做为JDBC的替代者出现的,而不是Entity Bean的替代者出现的,让我再列一次我已经列n次的框架结构:传统的架构:1) Session Bean Entity Bean DB为了解决性能障碍的替代架构:2) Session Bean DAO JDBC DB使用Hibernate来提高上面架构的开发效率的架构:3) Session Bean DAO Hibernate DB 就上面3个架构来分析:1、内存消耗采用JDBC的架构2无疑是最省内存的,Hibernate的架构3次之,EB的架构1最差。2、运行效率如果JDBC的代码写的非常优化,那么JDBC架构运行效率最高,但是实际项目中,这一点几乎做不到,这需要程序员非常精通JDBC,运用Batch语句,调整PreapredStatement的Batch Size和Fetch Size等参数,以及在必要的情况下采用结果集cache等等。而一般情况下程序员是做不到这一点的。因此Hibernate架构表现出最快的运行效率。EB的架构效率会差的很远。3、开发效率在有JBuilder的支持下以及简单的项目,EB架构开发效率最高,JDBC次之,Hibernate最差。但是在大的项目,特别是持久层关系映射很复杂的情况下,Hibernate效率高的惊人,JDBC次之,而EB架构很可能会失败。4、分布式,安全检查,集群,负载均衡的支持由于有SB做为Facade,3个架构没有区别。四、EB和Hibernate学习难度在哪里?EB的难度在哪里?不在复杂的XML配置文件上,而在于EB运用稍微不慎,就有严重的性能障碍。所以难在你需要学习很多EJB设计模式来避开性能问题,需要学习App Server和EB的配置来优化EB的运行效率。做EB的开发工作,程序员的大部分精力都被放到了EB的性能问题上了,反而没有更多的精力关注本身就主要投入精力去考虑的对象持久层的设计上来。Hibernate难在哪里?不在Hibernate本身的复杂,实际上Hibernate非常的简单,难在Hibernate太灵活了。当你用EB来实现持久层的时候,你会发现EB实在是太笨拙了,笨拙到你根本没有什么可以选择的余地,所以你根本就不用花费精力去设计方案,去平衡方案的好坏,去费脑筋考虑选择哪个方案,因为只有唯一的方案摆在你面前,你只能这么做,没得选择。Hibernate相反,它太灵活了,相同的问题,你至少可以设计出十几种方案来解决,所以特别的犯难,究竟用这个,还是用那个呢?这些方案之间到底有什么区别呢?他们的运行原理有什么不同?运行效率哪个比较好?光是主键生成,就有七八种方案供你选择,你为难不为难?集合属性可以用Set,可以用List,还可以用Bag,到底哪个效率高,你为难不为难?查询可以用iterator,可以用list,哪个好,有什么区别?你为难不为难?复合主键你可以直接在hbm里面配置,也可以自定义CustomerType,哪种比较好些?你为难不为难?对于一个表,你可以选择单一映射一个对象,也可以映射成父子对象,还可以映射成两个1:1的对象,在什么情况下用哪种方案比较好,你为难不为难?这个列表可以一直开列下去,直到你不想再看下去为止。当你面前摆着无数的眼花缭乱的方案的时候,你会觉得幸福呢?还是悲哀呢?如果你是一个负责的程序员,那么你一定会仔细研究每种方案的区别,每种方案的效率,每种方案的适用场合,你会觉得你已经陷入进去拔不出来了。如果是用EB,你第一秒种就已经做出了决定,根本没得选择,比如说集合属性,你只能用Collection,如果是Hibernate,你会在Bag,List和Set之间来回犹豫不决,甚至搞不清楚的话,程序都没有办法写。 Hibernate jar包的作用详解Hibernate一共包括了23个jar包,令人眼花缭乱。本文将详细讲解Hibernate每个jar包的作用,便于你在应用中根据自己的需要进行取舍。下载Hibernate,例如2.0.3稳定版本,解压缩,可以看到一个hibernate2.jar和lib目录下有22个jar包: hibernate2.jar Hibernate的库,没有什么可说的,必须使用的jar包。cglib-asm.jar CGLIB库,Hibernate用它来实现PO字节码的动态生成,非常核心的库,必须使用的jar包。 dom4j.jar dom4j是一个Java的XML API,类似于jdom,用来读写XML文件的。dom4j是一个非常非常优秀的Java XML API,具有性能优异、功能强大和极端易于使用的特点,同时它也是一个开放源代码的软件,可以在SourceForge上找到它。在IBM developerWorks上面可以找到一篇文章,对主流的Java XML API进行的性能、功能和易用性的评测,dom4j无论在那个方面都是非常出色的。我早在将近两年之前就开始使用dom4j,直到现在。如今你可以看到越来越多的Java软件都在使用dom4j来读写XML,特别值得一提的是连Sun的JAXM也在用dom4j。这是必须使用的jar包,Hibernate用它来读写配置文件。 odmg.jar ODMG是一个ORM的规范,Hibernate实现了ODMG规范,这是一个核心的库,必须使用的jar包。 commons-collections.jar Apache Commons包中的一个,包含了一些Apache开发的集合类,功能比java.util.*强大。必须使用的jar包。 commons-beanutils.jar Apache Commons包中的一个,包含了一些Bean工具类类。必须使用的jar包。 commons-lang.jar Apache Commons包中的一个,包含了一些数据类型工具类,是java.lang.*的扩展。必须使用的jar包。 commons-logging.jar Apache Commons包中的一个,包含了日志功能,必须使用的jar包。这个包本身包含了一个Simple Logger,但是功能很弱。在运行的时候它会先在CLASSPATH找log4j,如果有,就使用log4j,如果没有,就找JDK1.4带的java.util.logging,如果也找不到就用Simple Lmons-logging.jar的出现是一个历史的的遗留的遗憾,当初Apache极力游说Sun把log4j加入JDK1.4,然而JDK1.4项目小组已经接近发布JDK1.4产品的时间了,因此拒绝了Apache的要求,使用自己的java.util.logging,这个包的功能比log4j差的很远,性能也一般。后来Apache就开发出来了commons-logging.jar用来兼容两个logger。因此用commons-logging.jar写的log程序,底层的Logger是可以切换的,你可以选择log4j,java.util.logging或者它自带的Simple Logger。不过我仍然强烈建议使用log4j,因为log4j性能很高,log输出信息时间几乎等于System.out,而处理一条log平均只需要5us。你可以在Hibernate的src目录下找到Hibernate已经为你准备好了的log4j的配置文件,你只需要到Apache 网站去下载log4j就可以了。commons-logging.jar也是必须的jar包。 使用Hibernate必须的jar包就是以上的这几个,剩下的都是可选的。 ant.jar Ant编译工具的jar包,用来编译Hibernate源代码的。如果你不准备修改和编译Hibernate源代码,那么就没有什么用,可选的jar包。optional.jar Ant的一个辅助包。 c3p0.jar C3PO是一个数据库连接池,Hibernate可以配置为使用C3PO连接池。如果你准备用这个连接池,就需要这个jar包。proxool.jar 也是一个连接池,同上。 commons-pool.jar, commons-dbcp.jar DBCP数据库连接池,Apache的Jakarta组织开发的,Tomcat4的连接池也是DBCP。 实际上Hibernate自己也实现了一个非常非常简单的数据库连接池,加上上面3个,你实际上可以在Hibernate上选择4种不同的数据库连接池,选择哪一个看个人的偏好,不过DBCP可能更通用一些。另外强调一点,如果在EJB中使用Hibernate,一定要用App Server的连接池,不要用以上4种连接池,否则容器管理事务不起作用。 connector.jar JCA 规范,如果你在App Server上把Hibernate配置为Connector的话,就需要这个jar。不过实际上一般App Server肯定会带上这个包,所以实际上是多余的包。 jaas.jar JAAS是用来进行权限验证的,已经包含在JDK1.4里面了。所以实际上是多余的包。 jcs.jar 如果你准备在Hibernate中使用JCS的话,那么必须包括它,否则就不用。 jdbc2_0-stdext.jar JDBC2.0的扩展包,一般来说数据库连接池会用上它。不过App Server都会带上,所以也是多余的。 jta.jar JTA规范,当Hibernate使用JTA的时候需要,不过App Server都会带上,所以也是多余的。 junit.jar Junit包,当你运行Hibernate自带的测试代码的时候需要,否则就不用。 xalan.jar, xerces.jar, xml-apis.jar Xerces是XML解析器,Xalan是格式化器,xml-apis实际上是JAXP。一般App Server都会带上,JDK1.4也包含了解析器,不过不是Xerces,是Crimson,效率比较差,不过Hibernate用XML只不过是读取配置文件,性能没什么紧要的,所以也是多余的。附加源代码如下:package com.wbS.service;import java.util.ArrayList;import java.util.HashSet;import java.util.List;import java.util.Set;import org.hibernate.Session;import org.hibernate.Transaction;import com.wbS.entity.Attendance;import com.wbS.entity.Person;import com.wbStore.person.dao.AttendanceDAO;import com.wbStore.person.dao.impl.AttendanceDAOImpl;import com.wbStore.person.util.HbnUtil;/* * * author huangxh * */public class AttendanceServiceImpl implements AttendanceServiceTransaction tran=null;public void add(Attendance att) try Session s = HbnUtil.getCurrentSession();tran=s.beginTransaction();AttendanceDAO adao = new AttendanceDAOImpl();adao.save(att);System.out.println(att);mit(); catch (Exception e) if(tran!=null) tran.rollback();e.printStackTrace();public void update(Person person, Attendance att) Set set = new HashSet();AttendanceDAO service = new AttendanceDAOImpl();set = service.selectByPerson(person);for (Object obj : set) Attendance attendance = (Attendance) obj;System.out.println(321123+attendance.getAttendance_date();System.out.println(123321+att.getAttendance_date();if (attendance.getAttendance_date().equals(att.getAttendance_date() attendance.setNo(att.getNo();public List select(Person person, String str) List list=new ArrayList();try Session s = HbnUtil.getCurrentSession();tran=s.beginTransaction();AttendanceDAO dao = new AttendanceDAOImpl();list=dao.selectByDate(person, str);mit(); catch (Exception e) if(tran!=null) tran.rollback();e.printStackTrace();return list;package com.wbS.service;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import org.hibernate.Session;import org.hibernate.Transaction;import com.wbS.entity.Dept;import com.wbS.entity.Person;import com.wbStore.person.dao.DeptDAO;import com.wbStore.person.dao.impl.DeptDAOImpl;import com.wbStore.person.util.HbnUtil;/* * 部门业务的实现 * author huangxh * */public class DeptServiceImpl implements DeptService Transaction tran=null;public List selectByDept(Dept dept) DeptDAO dao = new DeptDAOImpl();List list = new ArrayList();try Session s = HbnUtil.getCurrentSession();tran = s.beginTransaction();Dept d=dao.select(dept);Iterator it=d.getPersons().iterator();while(it.hasNext()Person p=(Person)it.next();list.add(p);mit(); catch (Exception e) if(tran!=null) tran.rollback();e.printStackTrace();return list;public Dept selectDept(Dept dept) DeptDAO dao = new DeptDAOImpl();Dept d=null;try Session s = HbnUtil.getCurrentSession();tran = s.beginTransaction();d=dao.select(dept);mit(); catch (Exception e) if(tran!=null) tran.rollback();e.printStackTrace();return d;public void save(Dept dept) DeptDAO dao = new DeptDAOImpl();try Session s = HbnUtil.getCurrentSession();tran = s.beginTransaction();dao.save(dept);mit(); catch (Exception e) if(tran!=null) tran.rollback();e.printStackTrace();package com.wbS.service;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

人人文库网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。