多对多关联 用 中间表,求nhibernate中的HQL写法?我知道sql的写法
表 Group UserInGroup User
字段 GroupId UserId UserId
Name GroupId UserName
Intro
现在要,通过一个UserId,查询出该用户参见的所有组的信息
SQL是这样写的 SELECT g.GroupId,g.Name,g.Intro from Group g INNER JOIN UserInGroup uig on g.GroupId=uig.GroupId WHERE uig.UserId=@uid "
那HQL怎么写呢?
------解决方案--------------------基本差不多吧 SELECT g.GroupId as groupid,g.Name as name,g.Intro as intro from Group as g INNER JOIN UserInGroup as uig on g.GroupId=uig.GroupId WHERE uig.UserId=@uid
------解决方案--------------------select elements(a.Groups) from User a where a.UserId=?