关于java枚举类的一个问题
做一个加班订餐的系统,需求是用户类型为三种类型(管理员、部门主管、普通员工),管理员负责用户信息的增删改查,主管负责处理普通员工提交的申请,普通员工负责提交申请。我定义了...
做一个加班订餐的系统,需求是用户类型为三种类型(管理员、部门主管、普通员工),管理员负责用户信息的增删改查,主管负责处理普通员工提交的申请,普通员工负责提交申请。我定义了一个RtoUser的实体类,代码如下:
import java.io.Serializable;import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity // 表明该类 (RtoUser ) 为一个实体类,如果写成@Entity(RtoUserTable)它对应数据库中的表表名是RtoUserTable;
//写成@Entity则默认对应表RtoUser,和类名称相同public class RtoUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id //指定userName为主键
private String userName;
private String password;
private String department;
private String userType;
private int appliedID;
@OneToMany(mappedBy = "rtoUser") private List<RtoApplication> rtoApplicationList;
@Column(length = 30)
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Column(length = 30)
public int getAppliedID() {
return appliedID;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public void setAppliedID(int appliedID) {
this.appliedID = appliedID;
}
@Column(length = 30)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Column(length = 30)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<RtoApplication> getRtoApplicationList() {
return rtoApplicationList;
}
public void setRtoApplicationList(List<RtoApplication> rtoApplicationList) {
this.rtoApplicationList = rtoApplicationList;
}
}
可是测试时返回的userType却是个整数,不知为什么?求解 展开
import java.io.Serializable;import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity // 表明该类 (RtoUser ) 为一个实体类,如果写成@Entity(RtoUserTable)它对应数据库中的表表名是RtoUserTable;
//写成@Entity则默认对应表RtoUser,和类名称相同public class RtoUser implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
@Id //指定userName为主键
private String userName;
private String password;
private String department;
private String userType;
private int appliedID;
@OneToMany(mappedBy = "rtoUser") private List<RtoApplication> rtoApplicationList;
@Column(length = 30)
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
@Column(length = 30)
public int getAppliedID() {
return appliedID;
}
public String getUserType() {
return userType;
}
public void setUserType(String userType) {
this.userType = userType;
}
public void setAppliedID(int appliedID) {
this.appliedID = appliedID;
}
@Column(length = 30)
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Column(length = 30)
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public List<RtoApplication> getRtoApplicationList() {
return rtoApplicationList;
}
public void setRtoApplicationList(List<RtoApplication> rtoApplicationList) {
this.rtoApplicationList = rtoApplicationList;
}
}
可是测试时返回的userType却是个整数,不知为什么?求解 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询