日期:2014-05-17 浏览次数:20799 次
id username userage useraddress
1 wjf 29 通州
2 tbf 30 湖北
3 xxx 23 xxxxxx
id userid title content
1 1 test_title test_content
2 1 test_title2 test_content2
3 1 test_title3 test_content3
4 1 test_title4 test_content4
public class User {
private int id;
private String username;
private int userage;
private String useraddress ;
get和set方法...
}
public class Article {
private int id;
private User user;
private String title;
private String content;
get和set方法...
}
<resultMap id="resultUserArticleList" type="Article">
<id property="id" column="id" />
<result property="title" column="title" />
<result property="content" column="content" />
<association property="user" javaType="User">
<id property="id" column="id" />
<result property="username" column="userName" />
<result property="useraddress" column="userAddress" />
</association>
</resultMap>
<select id="getUserArticles" parameterType="int" resultMap="resultUserArticleList">
select u.id,u.username,u.useraddress,a.id,a.title,a.content from test_user u ,test_article a
where u.id=a.userid and u.id=#{id}
</select>
public interface IUserOperation {
public List&l