title: Hibernate Criteria API join entities without any association
body: <p>I'm trying to write a Hibernate Criteria API equivalent of the following SQL query:</p>
  
  <pre><code>select c.NAME         as carName,
     cc.COLOR_CODE      as colorCode,
     cc.COLOR           as color,
     c.DESCRIPTION      as desc,
     c.MANUFACTURE_YEAR as year
  from CAR c
       LEFT JOIN CAR_COLOR CC on c.COLOR_CODE_ID = CC.ID
  WHERE CC.COLOR_CODE = ?
  </code></pre>
  
  <p>This is my <code>Car</code> entity</p>
  
  <pre><code>public class Car extends BaseEntity {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private String name;
  
      @Basic
      @Column(name = "MANUFACTURE_YEAR")
      private String year;
  
      @Basic
      @Column(name = "DESCRIPTION")
      private String desc;
      private Long colorCodeId;
      private String manufacturer;
  }
  </code></pre>
  
  <p>and this is my <code>CarColor</code> entity</p>
  
  <pre><code>public class CarColor extends BaseEntity {
  
      @Id
      @GeneratedValue(strategy = GenerationType.AUTO)
      private Long id;
  
      private String color;
      private String colorCode;
  }
  </code></pre>
  
  <p><code>Car.colorCodeId</code> is a foreign key which references <code>CarColor.id</code>. Although there is no apparent entity-level relationship and I cannot add any relationships.</p>
  
  <p>I want to do a left join between these two tables/entities and map the result to <code>CarSearch</code>? How would I do this? Much appreciated. </p>
  
  <pre><code>public class CarSearch {
      private String carName;
      private String colorCode;
      private String color;
      private String desc;
      private String year;
  }
  </code></pre>