ImageVerifierCode 换一换
格式:DOCX , 页数:81 ,大小:425.30KB ,
资源ID:6326202      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/6326202.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Hibernate第五课.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Hibernate第五课.docx

1、Hibernate第五课第五课 员工管理系统的升级一、 使用Struts+Hibernate完成员工管理系统二、 建立数据库和表create database empdbgouse empdbgo-部门表create table dep( depid int identity primary key, depname varchar(50) unique)-职位表create table positions( pid int identity primary key, pname varchar(50) not null unique)-福利表create table welfare( wid

2、 int identity primary key, wname varchar(50) not null unique)-员工表create table emp( eid int identity primary key, ename varchar(50), sex varchar(4), address varchar(150), birthday datetime, depid int not null references dep(depid), pid int not null references positions(pid), photo image)-员工福利表create

3、table empwelfare( ewid int identity primary key, eid int not null references emp(eid), wid int not null references welfare(wid)-薪资表create table salary( sid int identity primary key, smoney money, eid int not null unique references emp(eid)-插入基础数据insert into dep values(技术部)insert into dep values(财务部)

4、insert into dep values(市场部)insert into dep values(行政部)insert into dep values(人事部)insert into dep values(研发部)insert into positions values(软件工程师)insert into positions values(系统设计师)insert into positions values(财务专员)insert into positions values(测试工程师)insert into positions values(行政专员)insert into positio

5、ns values(人事专员)insert into welfare values(三金)insert into welfare values(交通补助)insert into welfare values(住房补助)insert into welfare values(取暖费)insert into welfare values(降温费)insert into welfare values(通讯费)insert into welfare values(午餐费)关系图如下:三、 实现步骤1、 在当前工程引入struts和hibernate组件包2、 生成pojo类和dao类生成的实体类如下所示

6、:(1)Dep.javapackage com.po;import java.util.HashSet;import java.util.Set;public class Dep implements java.io.Serializable / Fields private Integer depid; private String depname; private Set emps = new HashSet(0); / Constructors /* default constructor */ public Dep() /* full constructor */ public Dep

7、(String depname, Set emps) this.depname = depname; this.emps = emps; / Property accessors public Integer getDepid() return this.depid; public void setDepid(Integer depid) this.depid = depid; public String getDepname() return this.depname; public void setDepname(String depname) this.depname = depname

8、; public Set getEmps() return this.emps; public void setEmps(Set emps) this.emps = emps; (2)Positions.javapackage com.po;import java.util.HashSet;import java.util.Set;public class Positions implements java.io.Serializable / Fields private Integer pid; private String pname; private Set emps = new Has

9、hSet(0); / Constructors /* default constructor */ public Positions() /* minimal constructor */ public Positions(String pname) this.pname = pname; /* full constructor */ public Positions(String pname, Set emps) this.pname = pname; this.emps = emps; / Property accessors public Integer getPid() return

10、this.pid; public void setPid(Integer pid) this.pid = pid; public String getPname() return this.pname; public void setPname(String pname) this.pname = pname; public Set getEmps() return this.emps; public void setEmps(Set emps) this.emps = emps; (3)Emp.javapackage com.po;import java.util.*;import java

11、.util.HashSet;import java.util.Set;/* * Emp entity. author MyEclipse Persistence Tools */public class Emp implements java.io.Serializable / Fields private Integer eid; private Positions positions=new Positions(); private Dep dep=new Dep(); private String ename; private String sex=男; private String a

12、ddress; private Date birthday; private byte photo; private Set empwelfares = new HashSet(0); private Set salaries = new HashSet(0); / Constructors /* default constructor */ public Emp() /* minimal constructor */ public Emp(Positions positions, Dep dep) this.positions = positions; this.dep = dep; /*

13、full constructor */ public Emp(Positions positions, Dep dep, String ename, String sex, String address, Date birthday, byte photo, Set empwelfares, Set salaries) this.positions = positions; this.dep = dep; this.ename = ename; this.sex = sex; this.address = address; this.birthday = birthday; this.phot

14、o = photo; this.empwelfares = empwelfares; this.salaries = salaries; / Property accessors public Integer getEid() return this.eid; public void setEid(Integer eid) this.eid = eid; public Positions getPositions() return this.positions; public void setPositions(Positions positions) this.positions = pos

15、itions; public Dep getDep() return this.dep; public void setDep(Dep dep) this.dep = dep; public String getEname() return this.ename; public void setEname(String ename) this.ename = ename; public String getSex() return this.sex; public void setSex(String sex) this.sex = sex; public String getAddress(

16、) return this.address; public void setAddress(String address) this.address = address; public Date getBirthday() return this.birthday; public void setBirthday(Date birthday) this.birthday = birthday; public byte getPhoto() return this.photo; public void setPhoto(byte photo) this.photo = photo; public

17、 Set getEmpwelfares() return this.empwelfares; public void setEmpwelfares(Set empwelfares) this.empwelfares = empwelfares; public Set getSalaries() return this.salaries; public void setSalaries(Set salaries) this.salaries = salaries; (4)Empwelfare.javapackage com.po;/* * Empwelfare entity. author My

18、Eclipse Persistence Tools */public class Empwelfare implements java.io.Serializable / Fields private Integer ewid; private Emp emp; private Welfare welfare; / Constructors /* default constructor */ public Empwelfare() /* full constructor */ public Empwelfare(Emp emp, Welfare welfare) this.emp = emp;

19、 this.welfare = welfare; / Property accessors public Integer getEwid() return this.ewid; public void setEwid(Integer ewid) this.ewid = ewid; public Emp getEmp() return this.emp; public void setEmp(Emp emp) this.emp = emp; public Welfare getWelfare() return this.welfare; public void setWelfare(Welfar

20、e welfare) this.welfare = welfare; (5)Welfare.javapackage com.po;import java.util.HashSet;import java.util.Set;/* * Welfare entity. author MyEclipse Persistence Tools */public class Welfare implements java.io.Serializable / Fields private Integer wid; private String wname; private Set empwelfares =

21、new HashSet(0); / Constructors /* default constructor */ public Welfare() /* minimal constructor */ public Welfare(String wname) this.wname = wname; /* full constructor */ public Welfare(String wname, Set empwelfares) this.wname = wname; this.empwelfares = empwelfares; / Property accessors public In

22、teger getWid() return this.wid; public void setWid(Integer wid) this.wid = wid; public String getWname() return this.wname; public void setWname(String wname) this.wname = wname; public Set getEmpwelfares() return this.empwelfares; public void setEmpwelfares(Set empwelfares) this.empwelfares = empwe

23、lfares; (6)Salary.javapackage com.po;/* * Salary entity. author MyEclipse Persistence Tools */public class Salary implements java.io.Serializable / Fields private Integer sid; private Emp emp; private Double smoney; / Constructors /* default constructor */ public Salary() /* minimal constructor */ p

24、ublic Salary(Emp emp) this.emp = emp; /* full constructor */ public Salary(Emp emp, Double smoney) this.emp = emp; this.smoney = smoney; / Property accessors public Integer getSid() return this.sid; public void setSid(Integer sid) this.sid = sid; public Emp getEmp() return this.emp; public void setE

25、mp(Emp emp) this.emp = emp; public Double getSmoney() return this.smoney; public void setSmoney(Double smoney) this.smoney = smoney; 3、 打开struts-config.xml文件,在设计视图建立ForemBean类和Action类,并设计访问流程。EmpForm类设计如下:/* * Generated by MyEclipse Struts * Template path: templates/java/JavaClass.vtl */package com.

26、zhhlk.struts.form;import javax.servlet.http.HttpServletRequest;import org.apache.struts.action.ActionErrors;import org.apache.struts.action.ActionForm;import org.apache.struts.action.ActionMapping;import org.apache.struts.upload.FormFile;import com.po.Emp;/* * MyEclipse Struts * Creation date: 05-03

27、-2012 * * XDoclet definition: * struts.form name=empForm */public class EmpForm extends ActionForm /* * Generated fields */ /* birthday property */ private String birthday; /* wid property */ private String wid;/用于获取页面显示的福利信息 /* upfile property */ private FormFile upfile;/文件上传的属性 /* salary property

28、*/ private String salary; /* emp property */ private Emp emp=new Emp(); /* * Generated Methods */ /* * Method validate * param mapping * param request * return ActionErrors */ public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) / TODO Auto-generated method stub return null; /* * Method reset * param mapping * param request */ public void reset(ActionMapping mapping, HttpServletRequest request) / TODO Auto-generated method stub /* * Returns the birthday. * return String

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1