public class User{
private int userId;
private String userName;
private Set<UserPic> userPic;
}
<set name="userPic" inverse="true" >
<key column="userId"/>
<one-to-many class="UserPic" />
</set>
public UserPic{
private int picId;
private String Title;
private String userPicPath;
private byte biaoZu;
}
<many-to-one name="user" cascade="delete"
class="User" column="userId" />
biaoZu默认为0
UserPic 有可能有图片,也有可能没有图片,有图片必有一张仅一张biaoZu为1;
我怎么才能用HQL查询组合列出所有User,如果有图片就User加UserPic biaoZu为1的那张图片,
如果没有图片就只列出User呢?
用from User as u left join fetch u.userPic p where p.buaoZu=1;只能列出有图片的User。高手能不能修改一下这条语句使实现上述功能?不胜感激!
------解决思路----------------------
没回复不可能得返回分