﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on NHibernate Queries: Find all users that are members of the same blogs as this user</title><description>No, create criteria means that you are now in a sub criteria, so the entity you now refer to is the user.
  
If I would have used the CreateAlias(), then I would have to do so.
  
  
"user.id" would work as well, btw.
</description><link>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment4</link><guid>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment4</guid><pubDate>Fri, 25 Jan 2008 15:31:21 GMT</pubDate></item><item><title>Craig Neuwirt commented on NHibernate Queries: Find all users that are members of the same blogs as this user</title><description>Maybe I am reading it wrong, but shouldn't the projection be something like
  
.SetProjection(Property.ForName("user.id")) so we get the related user ids?
</description><link>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment3</link><guid>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment3</guid><pubDate>Fri, 25 Jan 2008 15:26:03 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Queries: Find all users that are members of the same blogs as this user</title><description>Jon,
  
Yes, you are correct, I wasn't precise enough.
  
  
As for skipping the blog's join, it would be valid, but it is likely that using the fully path will allow the DB to utilize the FK indexes.
</description><link>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment2</link><guid>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment2</guid><pubDate>Thu, 24 Jan 2008 15:56:22 GMT</pubDate></item><item><title>Jon Skeet commented on NHibernate Queries: Find all users that are members of the same blogs as this user</title><description>I'm probably being stupid, but doesn't that SQL find the users that are members of *any* of the same blogs that the specified user is a member of? (Rather than all, as specified in the post.)
  
  
And out of interest, am I right in saying we don't actually need the join to Blogs at all? Assuming there are appropriate constraints, the subselect could be:
  
  
SELECT this_0_.Id AS y0_
  
FROM   Users this_0_
  
INNER JOIN UsersBlogs blogs4_
  
ON this_0_.Id = blogs4_.UserId
  
INNER JOIN UsersBlogs users6_
  
ON blogs4_.BlogId = users6_.BlogId
  
INNER JOIN Users user2_
  
ON users6_.UserId = user2_.Id
  
WHERE  this_0_.Id = @p0
  
  
Hopefully the query optimiser in the DB would figure this out though :)
  
  
Jon
</description><link>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment1</link><guid>http://ayende.com/3119/nhibernate-queries-find-all-users-that-are-members-of-the-same-blogs-as-this-user#comment1</guid><pubDate>Thu, 24 Jan 2008 14:58:17 GMT</pubDate></item></channel></rss>