日期:2014-05-17  浏览次数:20719 次

HIBERNATE 级联查询问题,求教O(∩_∩)O
Java code

//classroom MAPPING
public class Classroom {
private String id ;
private String name;
private Student student;

//SETTER AND GETTER;




Java code

//student MAPPING
public class Student {
private String uid ;
private String uname;
private String upsw;

//SETTER AND GETTER;




Java code

//执行方法
public List<Classroom > getClassroom (String cid) {
String hql = " from Classroom where id="+cid;
List<Classroom > classroomlist = getHibernateTemplate().find(hql);
return classroomlist ;



现状:getClassroom (String cid)会产生2条语句,一条是查询Class表的。另一条是查询Student 表的。

问:这就是级联查询?如何控制(取消)?请各位帮帮忙,呵呵

------解决方案--------------------
你的classroom里是不是配置了student关联,将配置设置为lazy=true