我有三个表:
- Person
- User
- PersonSecret
这里的PersonSecret是指Person和User之间的引用关系:
<class name="PersonSecret" table="PersonSecret" lazy="false" >
<id name="Id" column="Id" type="Guid">
<generator class="assigned"/>
</id>
...
<many-to-one name="Person" class="Person" foreign-key="FK_Person_PersonSecret" lazy="proxy" fetch="select">
<column name="PersonId"/>
</many-to-one>
<many-to-one name="User" class="User" foreign-key="FK_User_PersonSecret" lazy="proxy" fetch="select">
<column name="UserId"/>
</many-to-one>
这是从用户到个人机密信息的映射:
<set name="PersonSecrets" lazy="true" inverse="true" cascade="save-update" >
<key>
<column name="UserId"/>
</key>
<one-to-many class="PersonSecret"/>
这是来自个人到个人(P2P)秘密通信的内容:
<set name="PersonSecrets" lazy="true" inverse="true" cascade="save-update" >
<key>
<column name="PersonId"/>
</key>
<one-to-many class="PersonSecret"/>
现在,我尝试选择所有具有特定用户的PersonSecret条目的人员:
var query = this.Session.CreateQuery(@"from Person a inner join PersonSecret b
where b.UserId = :userId and b.RemindeBirthday = :remind");
这让我现在得到了异常信息:"需要为连接提供路径"。
有人能帮我吗,我做错了什么? - 谢谢。
from Person as a inner join a.PersonSecrets as b
。 - Enrico Campidoglio