我试图获取专辑细节,并与专辑相关的设置piSet
所有图像,但它不是取所有图像设置piSet
读取多联接数据集合
我要像
albumname in al object
ABC
images in piSet
image1
image2
image3
....
数据获取代码是
con = ConnectionFactory.getConnection();
List<Album> aList = new ArrayList<Album>();
try {
ps = con.prepareStatement("select distinct album.*,pi.* from "
+ "atom as a "
+ "left join album as album "
+ "on "
+ "a.id=album.aid "
+ "left join post_images as pi "
+ "on "
+ "album.id=pi.album_id "
+ "where "
+ "a.id=? "
+ "and a.status=? ");
ps.setLong(1, aid);
ps.setString(2, "Active");
rs = ps.executeQuery();
while (rs.next()) {
Set<PostImages> piSet = new HashSet<PostImages>();
Album al = new Album();
al.setId(rs.getLong("album.id"));
al.setName(rs.getString("album.name"));
PostImages pi = new PostImages();
pi.setImageId(rs.getLong("pi.image_id"));
pi.setLargePicPath(rs.getString("pi.large_pic_path"));
piSet.add(pi);
al.setPostImageses(piSet);
aList.add(al);
}
} catch (SQLException e) {}
如何修改上述代码以将所有图像提取到'PiSet'。