Hibernate 多对多查询HQL语句该怎么写?

nmhym0114 2012-10-22
User 类
	private String userId;
	private String userName;
	private String password;
	private String trueName;
	private Set Userroles = new HashSet(0);

Role 类
     private String roleId;
     private String roleName;
     private Set Userroles = new HashSet(0);


UserRole 类:
     private UserroleId id;

UserrroleId 类:
     private User User;
     private Role Role;


现在我要查询User类  并且User的状态为 1或者为5的人
要HQL   SQL我会写  但是 多出个UserroleID类  我就有点晕了.
这个是反向工程生成的
jinnianshilongnian 2012-10-22
select ur.user from UserRole ur where ur.user.状态 in (1,5)
nmhym0114 2012-10-22
jinnianshilongnian 写道
select ur.user from UserRole ur where ur.user.状态 in (1,5)

哥哥 UserRole类里 只有一个UserRoleID啊!
jinnianshilongnian 2012-10-22
nmhym0114 写道
jinnianshilongnian 写道
select ur.user from UserRole ur where ur.user.状态 in (1,5)

哥哥 UserRole类里 只有一个UserRoleID啊!


//这不是来两个对象吗?
UserrroleId
private User User; 
private Role Role;

select ur.user from UserrroleId ur where ur.user.状态 in (1,5)
nmhym0114 2012-11-05
jinnianshilongnian 写道
nmhym0114 写道
jinnianshilongnian 写道
select ur.user from UserRole ur where ur.user.状态 in (1,5)

哥哥 UserRole类里 只有一个UserRoleID啊!


//这不是来两个对象吗?
UserrroleId
private User User; 
private Role Role;

select ur.user from UserrroleId ur where ur.user.状态 in (1,5)

嗯  问题解决了  谢了!!!顺便能帮忙看下这个问题么
http://javaweb.group.iteye.com/group/topic/34949
一点头绪都没有  不知道该怎么弄好
Global site tag (gtag.js) - Google Analytics