title: Using the $in operator through Morphia - doing it wrong?
body: <p>I have the following Play Framework entity (using Morphia for persistence) as part of a generic blogging app:</p>
  
  <pre><code>@Entity
  public class Comment extends Model {
  
      ...
  
      @Reference
      @Indexed
      public SiteUser commenter;
  
      public static List&lt;Comment&gt; getLastCommentsByUsers(final List&lt;SiteUser&gt; users) {
          final Query&lt;Comment&gt; query ds().createQuery(Comment.class);
          query.field(commenter).hasAnyOf(users);
          return query.asList();
      }
  
  }
  </code></pre>
  
  <p>SiteUser:</p>
  
  <pre><code>@Entity(noClassnameStored=true)
  public class SiteUser extends AbstractUser {
  
      public String realName;
  
  }
  </code></pre>
  
  <p>AbstractUser:</p>
  
  <pre><code>public class AbstractUser extends Model {
  
      @Indexed(value= IndexDirection.DESC, unique = true)
      public String emailAddress;
  
      @Required
      public String password;
  }
  </code></pre>
  
  <p>The method <code>getLastCommentsByUsers()</code> is supposed to return all comments by the users in the <code>users</code> parameter, but I always get an empty <code>List</code> back. The reason that <code>Commment</code> is a separate collection is to be able to retrieve last X <code>Comment</code>s by certain users across their associated <code>Post</code>s, which isn't possible if the <code>Comment</code> is embedded in the <code>Post</code> collection.</p>
  
  <p>Is there something wrong with my query (should I be using something other than <code>hasAnyOf</code>), or is it a problem with the relationship mapping - should I be using <code>ObjectId</code> instead?</p>