开发者

Using Query or QueryOver to join on relationships that don't exist in objects

开发者 https://www.devze.com 2023-04-13 07:11 出处:网络
This may seem like a silly title but I\'m running into a small problem and I wasn\'t sure if there was another way around it.

This may seem like a silly title but I'm running into a small problem and I wasn't sure if there was another way around it.

I currently have the following entities:

Location <---> LocationContent --> Container <---> ContainerContent <--- OrderLine

The above entities relationships' are marked with the arrows. Location can have many LocationContent and a LocationCon开发者_Python百科tent has a link to it's parent Location etc.

My problem is that whenever I need to basically join all these tables (JoinAlias) to restrict my result set I'm unable to because not all of the above entities have bi-directional relationships. In some cases it doesn't make sense for me to have bidirectional relationships because the user will never access the data that way. It really only seems to make sense when I'm querying data.

Are these bi-directional relationships a necessary evil for querying data with QueryOver and Query or is there another way around this that I'm not thinking about?


dotjoe nailed it down: you DO need those relationships.

Why do you think they are evil? they're free.

The only query method that allows freeform joins is HQL.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号