title: How to write Hibernate query for collections Set
body: <p>I have following Entity</p>
  
  <pre><code>@Entity
  public class Employee{
  
      private Integer id;
      private String name;
      private String address;
      private Date created;
      @OneToMany(mappedBy = "employee")
      private Set&lt;Language&gt; languages = new HashSet&lt;AlbumUser&gt;()
  }
  </code></pre>
  
  <p>and Language entity is </p>
  
  <pre><code>  @Entity
      public class Language{
  
      private String name;
      @ManyToOne
      @JoinColumn(name = "employee_id") 
      private Employee employee;
  }
  </code></pre>
  
  <p>my language table looks like following</p>
  
  <p><img src="https://i.stack.imgur.com/zHjYS.png" alt="enter image description here"></p>
  
  <p>I want to select all employee whose name starts with A and who knows java and C and to do so I am trying following</p>
  
  <pre><code>DetachedCriteria criteria = DetachedCriteria.forClass(Employee.class,"employee");
   criteria.add( Restrictions.ilike("name", "A%") );
   criteria.add(Restrictions.in("languages",languageSet));
   return getHibernateTemplate().findByCriteria(criteria)
  </code></pre>
  
  <p>where languageSet is </p>
  
  <pre><code>Set&lt;Language&gt; languageSet = new HashSet();
  languageSet.add(new Language("Java"));
  languageSet.add(new Language("C"));
  </code></pre>
  
  <p>I can see my attempt is completely wrong...I am new to hibernate can some one please help me with it..</p>
  
  <pre><code>Caused by: java.sql.SQLException: No value specified for parameter 2
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
      at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2176)
      at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:2100
  </code></pre>