hibernate查询出来的对象(有set和get方法)中为什么不能获得那个对象中外键其他的对象 5
teacher和appointment外键关联一对多,publicclassAppointmentimplementsjava.io.Serializable{priva...
teacher和appointment外键关联一对多,
public class Appointment implements java.io.Serializable {
private Integer id;
private Student student;
private Teacher teacher;
private Integer time;
private Timestamp date;
private Integer content;
。。。。setter,getter();
}
public class Teacher implements java.io.Serializable {
private Integer id;
private String name;
private Integer sex;
private Integer age;
setter,getter();
}
dao层中查询出所有appoinment。
public List<Appointment> queryAppoinment() {
// TODO Auto-generated method stub
return getSession().createQuery(hql).list();
}
在一个工具类中要将list转换成json
appointment.getId()不出错
appointment.getTeacher().getId()调试的时候报source not found; 展开
public class Appointment implements java.io.Serializable {
private Integer id;
private Student student;
private Teacher teacher;
private Integer time;
private Timestamp date;
private Integer content;
。。。。setter,getter();
}
public class Teacher implements java.io.Serializable {
private Integer id;
private String name;
private Integer sex;
private Integer age;
setter,getter();
}
dao层中查询出所有appoinment。
public List<Appointment> queryAppoinment() {
// TODO Auto-generated method stub
return getSession().createQuery(hql).list();
}
在一个工具类中要将list转换成json
appointment.getId()不出错
appointment.getTeacher().getId()调试的时候报source not found; 展开
1个回答
2015-06-25
展开全部
没有打开事务,如果打开了还不行 就try catch一些 跟更新部分代码 看报什么错误了。
追问
查询是不用打开事物的吧,而且我的事物管理都是交给spring 的
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询