title: Hibernate: @ManyToOne(fetch = FetchType.LAZY) does not work on non-primary key referenced column
body: <p>I have 2 tables: <code>Order [OrderId(PK), OrderShipmentCode, ...]</code> and <code>Shipment[ShipmentId(PK), ShipmentCode, ...]</code>.</p>
  
  <p>In <code>Order</code> class, I declared <code>shipment</code> field as follows:</p>
  
  <pre><code>@ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = "OrderShipmentCode", referencedColumnName = "ShipmentCode", insertable = false, updatable = false, nullable = false)
  private Shipment shipment;
  </code></pre>
  
  <p>When I get the list of <code>Order</code>, the <code>Shipment</code> is also loaded (I saw many separate SELECT queries). But I want the <code>Shipment</code> to be lazy loaded, not to be fetched together with <code>Order</code>.</p>
  
  <p>For other tables, if the referenced column is primary key then the results are as expected (Lazy-loading is used). In my case, <code>ShipmentCode</code> is not Primary Key of <code>Shipment</code> table, and lazy-loading is not used by Hibernate.</p>
  
  <p>Could you show me how to accomplish that goal?</p>
  
  <p><strong>EDIT:</strong>
  The Query code is as bellow:</p>
  
  <pre><code>Criteria criteria = HibernateUtil.getSessionFactory().getCurrentSession().createCriteria(Order.class);
  List result = criteria.list();
  </code></pre>
  
  <p>SQL queries are: 1 SELECT statement for <code>Order</code> table and a bunch of SELECT statement for <code>Shipment</code></p>