title: Hibernate Criteria.createAlias not joining tables
body: <p>I have this two entities:</p>
  
  <pre><code>@Entity
  @Table(name = "BA_USER", schema = "MYSCHEMA")
  @XmlType(namespace = BusinessOperations.NAMESPACE)
  @JsonIgnoreProperties(ignoreUnknown = true)
  public class UserWeb implements Serializable, UserDetails, SecurityUserInfo, Auditable {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO, generator = "userGenerator")
      @SequenceGenerator(name="userGenerator", sequenceName="SEQ_USER")
      @Column(name = "USERID", unique = true, nullable = false, precision = 22, scale = 0)
      private long userid;
  
      @ManyToOne(targetEntity = Country.class, fetch = FetchType.LAZY)
      @JoinColumn(name = "COUNTRYID")
      private Country country;
  
      @ManyToOne(targetEntity = Menu.class, fetch = FetchType.LAZY)
      @JoinColumn(name = "MENUID")
      private Menu menu;
  
      //Getters and Setters
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>@Entity
  @Table(name = "BA_PREMIUMUSER", schema = "MYSCHEMA")
  public class PremiumUser implements java.io.Serializable {
  
      @Id
      @OneToOne(targetEntity = UserWeb.class, fetch = FetchType.LAZY)
      @JoinColumn(name = "USERID")
      private UserWeb userWeb;
  
      @ManyToOne(targetEntity = Customer.class, fetch = FetchType.LAZY)
      private Customer customer;
  
      //Getters and Setters
  }
  </code></pre>
  
  <p>Then, in my DAO I have the following method:</p>
  
  <pre><code>public List&lt;PremiumUser&gt; findAllUsers(Long userid, Long customerId, Menu menu) {
  
      Criteria criteria = getSession().createCriteria(PremiumUser.class);
  
      criteria.add(Restrictions.eq("clienteProsegur", customerId));
      criteria.createAlias("userWeb", "userweb", CriteriaSpecification.INNER_JOIN);
      criteria.add(Restrictions.eq("userweb.menu", menu));
  
      return criteria.list();
  }
  </code></pre>
  
  <p>Hibernate is creating the following query:</p>
  
  <pre><code>select this_.USERID as USERID52_0_, this_.CUSTOMER as CUSTOMER2_52_0_ 
  from MYSCHEMA.BA_PREMIUMUSER this_ 
  where userweb1_.MENUID=2 and this_.CUSTOMERID=3
  </code></pre>
  
  <p>I expected the createAlias method to create a join statement in the query, like this_</p>
  
  <pre><code>select this_.USERID as USERID52_0_, this_.CUSTOMER as CUSTOMER2_52_0_ 
  from MYSCHEMA.BA_PREMIUMUSER this_ 
  inner join MYSCHEMA.BA_USER userweb1_ on this_.USERID = userweb1.USERID
  where userweb1_.MENUID=2 and this_.CUSTOMERID=3
  </code></pre>
  
  <p>I'm using this version of hibernate: <code>Hibernate-core-3.6.0.Final</code></p>
  
  <p>I think I'm missing something here.</p>