title: lazy loading for one to many does not work for hibernate and lombok
body: <p>Lazy loading for one to many does not work</p>
  
  <p>I have the following Order entity</p>
  
  <pre><code>@Data
  @Entity
  @EqualsAndHashCode
  @Table(name = Order.TABLE_NAME)
  public class Order implements Serializable {
  
  private static final long serialVersionUID = -7036337819884484941L;
  
  @Column(name = OrderNames.ORDER_ID)
  private String orderId;
  
  @Column
  private String name;
  
  @JsonManagedReference
  @ToString.Exclude
  @OneToMany(mappedBy = "order", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
  private Set&lt;OrderItem&gt; orderItem = new HashSet&lt;&gt;();
  </code></pre>
  
  <p>and I have another entity OrderItem</p>
  
  <pre><code>@Data
  @Entity
  @EqualsAndHashCode(callSuper = true, exclude = "order")
  @Table(name = OrderItemNames.TABLE_NAME)
  public class OrderItem implements Serializable {
  
  private static final long serialVersionUID = -7036337819884484941L;
  
  @Column(name = OrderItemNames.ORDER_ID)
  private String orderId;
  
  @Column(name = OrderItemNames.ORDER_ITEM_ID)
  private String orderItemId;
  
  @JsonBackReference
  @ToString.Exclude
  @ManyToOne(fetch = FetchType.LAZY)
  @JoinColumn(name = OrderItemNames.ORDER_FK, nullable = false)
  private Order order;
  </code></pre>
  
  <p>Here is my repository</p>
  
  <pre><code>@Repository
  public interface OrderRepository extends JpaRepository&lt;Order, String&gt; {
      Order findByOrderId(String orderId);
  }
  </code></pre>
  
  <p>And here is my ServiceImpl</p>
  
  <pre><code>@Override
  public Order findByOrderId(String orderId) {
      Order order = orderRepository.findByOrderId(orderId);
  
      return order;
  }
  </code></pre>
  
  <p>From my understanding,
  if I debug on the orderRepository.findByOrderId, I expect it will only show Order entity (without OrderItem) because the fetch type is lazy</p>
  
  <p>But the actual result is eager and the order has the orderItem entity as well regardless if I do it eagerly / lazily.</p>
  
  <p>I have followed this as well <a href="https://stackoverflow.com/a/37727206/6460497">https://stackoverflow.com/a/37727206/6460497</a> but to no avail.
  Do I miss something regarding the ToString or @EqualsAndHashCode ?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I turned on the SQL logging and it does 2 queries (select the order table and then select the orderItem table). This happens on both eager and lazy loading.</p>
  
  <p>I also tried to remove lombok @Data and use @Getter @Setter create my own equal hashCode and toString, but it still load the data even if i set it to lazy.</p>
  
  <p>Here is my properties to postgreSql</p>
  
  <pre><code>spring.jpa.database=postgresql
  spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
  spring.jpa.show-sql=false
  spring.jpa.hibernate.ddl-auto=none
  spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
  spring.jpa.properties.hibernate.default_schema=public
  spring.jpa.properties.hibernate.show_sql=true
  spring.jpa.open-in-view = false
  
  hibernate.show_sql=true
  hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
  hibernate.format_sql=true
  hibernate.hbm2ddl.auto=
  
  spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
  spring.datasource.username=username
  spring.datasource.password=password
  </code></pre>