配置一对多导致json转换错误,数据无法展现的问题
2014-03-26 23:49
666 查看
请假表:
public void setEmployeeName(java.lang.String employeeName) {
this.employeeName = employeeName;
}
private EmployeeEntity employeeEntity;
@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER,optional=true)
public EmployeeEntity getEmployeeEntity() {
return employeeEntity;
}
public void setEmployeeEntity(EmployeeEntity employeeEntity) {
this.employeeEntity = employeeEntity;
}
@Transient
public java.lang.String getEmployeeName() {
if(employeeEntity != null){
return employeeEntity.getEmployeeName();
}else{
return "";
}
}
public void setEmployeeName(java.lang.String employeeName) {
this.employeeName = employeeName;
}
员工表:
@OneToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY, targetEntity = AbsenceEntity.class, mappedBy = "employeeEntity")
public List<AbsenceEntity> getAbsenceList() {
return absenceList;
}
public void setAbsenceList(List<AbsenceEntity> absenceList) {
this.absenceList = absenceList;
}
如果请假表里面找不到员工表信息,就会出错,之所以找不到,可能是数据在进入请假表时候,没有产生关联关系
比如我先在请假表里面产生了数据,后来才配置一对多关系,所以先前的数据时没有被关系维护的,所以
也就找不到员工表信息了,所以获取员工名称就会出现问题,而红色部分是我后来添加的,判断如果是null的情况,
这样,就算找不到员工信息,也不会导致请假表数据显示不出来了
public void setEmployeeName(java.lang.String employeeName) {
this.employeeName = employeeName;
}
private EmployeeEntity employeeEntity;
@ManyToOne(cascade=CascadeType.ALL,fetch=FetchType.EAGER,optional=true)
public EmployeeEntity getEmployeeEntity() {
return employeeEntity;
}
public void setEmployeeEntity(EmployeeEntity employeeEntity) {
this.employeeEntity = employeeEntity;
}
@Transient
public java.lang.String getEmployeeName() {
if(employeeEntity != null){
return employeeEntity.getEmployeeName();
}else{
return "";
}
}
public void setEmployeeName(java.lang.String employeeName) {
this.employeeName = employeeName;
}
员工表:
@OneToMany(cascade = { CascadeType.REFRESH }, fetch = FetchType.LAZY, targetEntity = AbsenceEntity.class, mappedBy = "employeeEntity")
public List<AbsenceEntity> getAbsenceList() {
return absenceList;
}
public void setAbsenceList(List<AbsenceEntity> absenceList) {
this.absenceList = absenceList;
}
如果请假表里面找不到员工表信息,就会出错,之所以找不到,可能是数据在进入请假表时候,没有产生关联关系
比如我先在请假表里面产生了数据,后来才配置一对多关系,所以先前的数据时没有被关系维护的,所以
也就找不到员工表信息了,所以获取员工名称就会出现问题,而红色部分是我后来添加的,判断如果是null的情况,
这样,就算找不到员工信息,也不会导致请假表数据显示不出来了
相关文章推荐
- WIN7下.Net开发遇到的又一问题:HTTP 错误 500.19 - Internal Server Error,无法访问请求的页面,因为该页的相关配置数据无效。
- var dataObj=eval("("+data+")");//转换为json对象(解决在ajax返回json格式数据的时候明明正确的获取了返回值但是却就是进不去success方法的问题。格式错误)
- WIN7下.Net开发遇到的又一问题:HTTP 错误 500.19 - Internal Server Error,无法访问请求的页面,因为该页的相关配置数据无效。
- 微信小程序:wx.navigateTo中url无法跳转问题(app.json中配置的tabBar与wx.navigateTo中url引用相同页面导致)
- SSH框架问题——hbm.xml配置出现的org.hibernate.MappingException: Could not determine type for:(貌似叫数据类型转换错误)问题
- A网站引用B服务器虚拟目录文件导致:网站部署到IIS7上出现HTTP 错误 500.19(由于权限不足而无法读取配置文件)的问题
- wamp因配置错误而导致apache无法启动的问题
- Apache页面压缩配置问题导致json数据传输时间延长
- 微信小程序——wx.navigateTo中url无法跳转问题(app.json中配置的tabBar与wx.navigateTo中url引用相同页面导致)(2017/12)
- Apache页面压缩配置问题导致json数据传输时间延长
- Apache页面压缩配置问题导致json数据传输时间延长
- HTTP 错误 404.3 - Not Found 由于扩展配置问题而无法提供您请求的页面。
- 遭遇“HTTP 错误 500.19 无法访问请求的页面,因为该页的相关配置数据无效。”处理
- HTTP 错误 500.19 - Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效。
- VS2010 clickonce发布错误:因为某项目未能生成,所以无法发布 非签名问题导致产生的错误
- 关于springMVC 4.x配置ajax-json 出现406错误的问题。
- Tomcat中Set-Cookie的Domain错误导致无法登录问题
- tomcat ssi配置及升级导致ssi include错误问题解决
- IIS HTTP 错误 500.19 - Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效
- 解决fastjson、Jackson、Gson解析Json数据时,key为Java中关键字无法解析的问题