title: Can I add Restriction.eq() for list?
body: <p>I have this piece of code:</p>
  
  <pre><code>public String getEventsForCalendar(@RequestParam("userId") Long userId){
    Session session = NewHibernateUtil.getSessionFactory().getCurrentSession();
      try{
          session.beginTransaction();
          JSONArray eventsArray = new JSONArray((List&lt;Event&gt;)(session.createCriteria(Event.class)
                  .add(Restrictions.eq("ownerid", userId))
                  .list()));
          User user = (User)session.createCriteria(User.class)
                  .add(Restrictions.eq("id", userId)).uniqueResult();
          for (Event event: (List&lt;Event&gt;) session.createCriteria(Event.class)
                  .add(Restrictions.ne("ownerid", userId))
                  .list()){
              if (event.getInvited().contains(user)){
                  eventsArray.put(new JSONObject(event));
              }
          }
      }
      catch(Exception e){
          System.out.println(e.getMessage());
      }
      return null;
   }
  </code></pre>
  
  <p>It, at first, should find Events created by User. Next, in loop it should get Events which User is invited. Each Events has List called invited and I think I have to iterate over all list and check if User is in invited list, but can I do something like? </p>
  
  <pre><code>List&lt;Event&gt; list = session(...)
      .add(Restrictions.eq("invited", user);
  </code></pre>
  
  <p>In the other words, can I get from database Object which in list contains object? I will be very happy if anybody answers my question - thank you in advance.</p>