package ccpit.base.role; import java.util.ArrayList; import java.util.List; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.ManyToMany; import javax.persistence.OneToMany; import ccpit.base.modol.BaseEntity; import ccpit.base.orgManage.OrgInfo; import ccpit.base.user.User; import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Where; import com.fasterxml.jackson.annotation.JsonIgnore; /** * * ClassName: Role <br/> * Function: TODO ADD FUNCTION. <br/> * Reason: TODO ADD REASON(可选). <br/> * date: 2015年4月14日 下午2:15:28 <br/> * * @author dingwei * @version * @since JDK 1.6 */ @Entity @Cache(usage = CacheConcurrencyStrategy.READ_WRITE) @Where(clause="whetherDelete = 'false'") public class Role extends BaseEntity implements IRole { private String roleName; private List<RoleUrl> urlPerfixs = new ArrayList<RoleUrl>(); private String description; private boolean whetherDelete; @JsonIgnore private List<User> userList = new ArrayList<User>(); @JsonIgnore private List<OrgInfo> orgList = new ArrayList<OrgInfo>(); @Override @Id @GeneratedValue(strategy = GenerationType.AUTO) public long getId() { return super.getId(); } @Override public String getRoleName() { return roleName; } public void setRoleName(String roleName) { this.roleName = roleName; } @Override @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER) public List<RoleUrl> getUrlPerfixs() { return urlPerfixs; } public void setUrlPerfixs(List<RoleUrl> urlPerfixs) { this.urlPerfixs = urlPerfixs; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } @Override public int hashCode() { return ("role"+getId()).hashCode(); } @Override public boolean equals(Object o) { if(o == null){ return false; } if(o == this){ return true; } if(o.getClass() == Role.class){ return o.hashCode()==this.hashCode(); } return false; } @ManyToMany(fetch=FetchType.LAZY,cascade = CascadeType.PERSIST,mappedBy="roles") public List<User> getUserList() { return userList; } public void setUserList(List<User> userList) { this.userList = userList; } @ManyToMany(fetch=FetchType.LAZY,cascade = CascadeType.PERSIST,mappedBy="roles") public List<OrgInfo> getOrgList() { return orgList; } public void setOrgList(List<OrgInfo> orgList) { this.orgList = orgList; } public boolean isWhetherDelete() { return whetherDelete; } public void setWhetherDelete(boolean whetherDelete) { this.whetherDelete = whetherDelete; } }