日期:2014-05-16  浏览次数:20450 次

Spring3.0+Struts2.2+Hibernate3.6+ExtJS3.2.0+DWR框架 整合一
一、系统构建
1、数据持久层用Hibernate注释,数据库表根据配置自动生成。
@Entity
@Table(name = "t_user")
public class User {

private int id;
private String user_code;
private String pwd;// 用户密码
private String name;// 用户姓名
private String sex;// 用户性别
private String email;// 用户email
private int creator_id;// 用户创建者id
private Date created_dt = new Date();// 创建日期
private int del_flag;// 删除标志

private Popedom popedom;// 身份对象
private Department department;// 部门对象

/*
* @Id
*
* @GenericGenerator(name = "idGenerator", strategy = "uuid") //
* 这个是hibernate的注解
*
* @GeneratedValue(generator = "idGenerator") // 使用uuid的生成策略
*/
@Id
@GeneratedValue
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

@Column(unique = true)
public String getUser_code() {
return user_code;
}

public void setUser_code(String user_code) {
this.user_code = user_code;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getPwd() {
return pwd;
}

public void setPwd(String pwd) {
this.pwd = pwd;
}

public String getSex() {
return sex;
}

public void setSex(String sex) {
this.sex = sex;
}

public String getEmail() {
return email;
}

public void setEmail(String email) {
this.email = email;
}

public int getCreator_id() {
return creator_id;
}

public void setCreator_id(int creator_id) {
this.creator_id = creator_id;
}

public int getDel_flag() {
return del_flag;
}

public void setDel_flag(int del_flag) {
this.del_flag = del_flag;
}

@ManyToOne(cascade = { CascadeType.REFRESH })
public Popedom getPopedom() {
return popedom;
}

public void setPopedom(Popedom popedom) {
this.popedom = popedom;
}

@ManyToOne(cascade = { CascadeType.REFRESH })
public Department getDepartment() {
return department;
}

public void setDepartment(Department department) {
this.department = department;
}

public Date getCreated_dt() {
return created_dt;
}

public void setCreated_dt(Date created_dt) {
this.created_dt = created_dt;
}
}
/**
* 权限类
*
* @author
*/
@Entity
@Table(name = "t_popedom")
public class Popedom {
private int id;// id
private String status;// 身份
private Set<User> users = new HashSet<User>();// 属于该身份的成员
@Id
@GeneratedValue
public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getStatus() {
return status;
}

public void setStatus(String status) {
this.status = status;
}
@OneToMany(mappedBy="popedom")
public Set<User> getUsers() {
return users;
}

public void setUsers(Set<User> users) {
this.users = users;
}

}
/**
* 部门类
*
* @author
*/
@Entity
@Table(name = "t_department")
public class Department {
private Integer id;// 部门id
private String name;// 部门名称
private String description;// 部门描述

private User director;// 部门主管




private Set<User> users = new HashSet<User>();// 部门成员

@Id
@GeneratedValue
public Integer getId() {
return id;
}