title: Hibernate: exception when using embeddable in HQL query
body: <p>I've got a shopping application with customers. Those customers have a cart containing products. Here's the (simplified) mapping with embeddables I used:</p>
  
  <pre><code>@Entity
  class Customer {
  
    @Embedded
    private Cart cart;
  
    // Constructors, setters, equals... omitted
  }
  
  @Embeddable
  class Cart {
  
    @ElementCollection
    @JoinTable(name = ...)
    private Set&lt;Product&gt; products = new HashSet&lt;&gt;();
  
    ...   
  }
  
  @Embeddable
  class Product {
  
    private String name;
  
    ...
  }
  </code></pre>
  
  <p>Now, I'm trying to get a customer's cart with HQL. I know I can't directly query embeddables, but nothing prevents me from selecting it as a field:</p>
  
  <pre><code>select c.cart from Customer c where c.id = 1
  </code></pre>
  
  <p>but this results in the following exception:</p>
  
  <pre><code>Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at org.hibernate.hql.ast.util.ColumnHelper.generateScalarColumns(ColumnHelper.java:62)
      at org.hibernate.hql.ast.tree.DotNode.setScalarColumnText(DotNode.java:661)
      at org.hibernate.hql.ast.tree.SelectClause.renderScalarSelects(SelectClause.java:359)
  ...
  </code></pre>
  
  <p>I could overcome this problem by just retrieving the customer and traverse its getCart() method, but I wonder if this issue is caused by an incorrect mapping or something like that. Thanks a lot!</p>