title: using projections on multiple columns - joined tables
body: <p>Good day.</p>
  
  <p>So i have mapping 
     @Id
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "discount_fares_id_sequence")
      @SequenceGenerator(
          name = "discount_fares_id_sequence",
          sequenceName = "discount_fares_id_seq",
          allocationSize = 1
      )
      private Long id;</p>
  
  <pre><code>@Column
  private Long discount;
  
  @Column(name = "fare_code", length = 255)
  private String fareCode;
  
  @ManyToOne
  @JoinColumn(name = "aircompany_id", foreignKey = @ForeignKey(name = "fk_discfares_ref_aircompany_id"))
  private AircompanyRB aircompanyId;
  </code></pre>
  
  <p>how do i use projections to extract only</p>
  
  <p>discountFare id
  discount
  fareCode
  and aircompany_id   (the key of AircompanyRB)</p>
  
  <p>So basically all the fields of DiscountFares plus only key of AircompanyRB?</p>
  
  <p>I tried</p>
  
  <pre><code>    DetachedCriteria criteria = DetachedCriteria.forClass(DiscountFares.class)
          .createCriteria("aircompanyId")
          .setProjection(Projections.projectionList()
          .add(Projections.property("id"))
          .add(Projections.property("discount"))
          .add(Projections.property("fareCode")));
  
      List&lt;DiscountFares&gt; result = criteria.getExecutableCriteria(sessionFactory.getCurrentSession()).list();
  </code></pre>
  
  <p>but it throws exception saying AircompanyRB doesnt have a field "discount"
  (yes, it does not-  DiscountFares have)</p>
  
  <p>thank you very much!
  any help is highly appreciated</p>