title: org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor
body: <p>I have 2 tables mapped to entities <code>User</code> and <code>Group</code>.</p>
  
  <pre><code>@Entity
  @Table(name = "T_COM_USER")
  public class User {
      private String userName;
      @Column(name="F_USERNAME", length=60)
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
  }
  </code></pre>
  
  
  
  <pre><code>@Entity
  @Table(name="T_COM_USERGROUP")
  public class UserGroup{
      private String groupName;
      @Column(name="F_GROUPNAME", length=60)
      public String getGroupName() {
          return groupName;
      }
      public void setGroupName(String groupName) {
          this.groupName = groupName;
      }
  }
  </code></pre>
  
  <p>One <code>User</code> can have many <code>Group</code>s. I need to model them in order to display the users with all their groups in a table in the frontend like below:</p>
  
  <pre><code>+-------+----------------------+
  | Users |        Groups        |
  +-------+----------------------+
  | User1 | Group1,Group2,Group3 |
  | User2 | Group1,Group2        |
  | User3 | Group2,Group4        |
  +-------+----------------------+
  </code></pre>
  
  <p>So I created this DTO:</p>
  
  <pre><code>public class UserGroupsBean {
      private List&lt;String&gt; groupName;
      private String userName;
      public UserGroupsBean(String userName, List&lt;String&gt; groupName) {
          this.userName = userName;
          this.groupName = groupName;
      }
      // Getters
      public List&lt;String&gt; getGroupName() { return groupName; }
      public String getUserName() { return userName; }            
      // Setters
      public void setGroupName(List&lt;String&gt; groupName) { this.groupName = groupName; }
      public void setUserName(String userName) { this.userName = userName;}
  }
  </code></pre>
  
  <p>I used this query to return all the groups for each user:</p>
  
  <pre><code>String hql = "select new odatabase.service.beans.UserGroupsBean(userName,(select groupName from UserGroup) ) from User";
  </code></pre>
  
  <p>But I got:</p>
  
  <blockquote>
    <p>org.hibernate.hql.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [UserGroupsBean]</p>
  </blockquote>
  
  <p>Although I have a constructor <code>UserGroupsBean(String userName, List &lt; String &gt; groupName)</code></p>
  
  <p>How is this caused and how can I solve it ?</p>