您好,欢迎来到[编程问答]网站首页   源码下载   电子书籍   软件下载   专题
当前位置:首页 >> 编程问答 >> Java >> ibatis一对多关联查询为什么子查询不执行

ibatis一对多关联查询为什么子查询不执行

来源:网络整理     时间:2016/7/31 9:52:28     关键词:

关于网友提出的“ ibatis一对多关联查询为什么子查询不执行”问题疑问,本网通过在网上对“ ibatis一对多关联查询为什么子查询不执行”有关的相关答案进行了整理,供用户进行参考,详细问题解答如下:

问题: ibatis一对多关联查询为什么子查询不执行
描述:

刚开始接触ibatis,一对多关联查询时遇到问题。
StuClass和Student为一对多关系。
2张表为Student:
字段:sid,sname,classid
StuClass:
字段:classid,classname
2个实体类如下


public class Student {
private Integer sid;
private String sname;
private StuClass classid;
//省略get,set
}
public class StuClass {
private Integer classid;
private String classname;
private List students;
}

配置文件如下:












select * from class where classid=#classid#


select * from student where classid = #classid#


查询StuClass时不能把关联的Student一起查出来,是不是配置文件写的不对,应该怎么改?
解决方案1:

select要用resultMap[code=Java
    select * from class where classid=#classid#

[/code]


以上介绍了“ ibatis一对多关联查询为什么子查询不执行”的问题解答,希望对有需要的网友有所帮助。
本文网址链接:http://www.codes51.com/itwd/3048289.html

相关图片

相关文章