title: Kotlin - HibernateProxy not loaded when calling a getter
body: <p>I'm currently converting an existing Java project to Kotlin, and I'm running into some issues about Hibernate Lazy Loading behavior.</p>
  
  <p>In the following data model (simplified) :</p>
  
  <pre><code>@Entity
  open class Parent
  {
      @Id
      @GeneratedValue
      var id: Long = 0
  
      @OneToOne(fetch = FetchType.LAZY, mappedBy = "parent", cascade = [CascadeType.ALL], optional = false)
      open var child = Child(this)
  }
  
  @Entity
  open class Child(@MapsId
                   @OneToOne(fetch = FetchType.LAZY)
                   @JoinColumn(name = "parent_id", insertable = false, updatable = false)
                   val parent: Parent)
  {
      @Id
      private val parentId: Long = 0
  
      // Its actual type is not relevant, as long as it is not a primitive type
      var whateverAttributeFromChild: AnyComplexType
  }
  </code></pre>
  
  <p>The Lazy Loading seem to work as expected (when I query a <code>Parent</code>, the <code>child</code> attribute is represented by a subclass of <code>HibernateProxy</code>, and in the database, the <code>Child</code> table is not queried).</p>
  
  <p>However, when I run <code>parent.child</code> in my application, Hibernate does not load the child.
  That means : If I call <code>parent.child.whateverAttributeFromChild</code>, the <code>whateverAttributeFromChild</code> will be NULL (because it is not loaded).</p>
  
  <p>I can't find a way to tell Hibernate to load the lazy attributes when accessed (and I don't want to manually unproxy every lazy attribute from my application).</p>
  
  <p>Does anyone have a solution for this ?</p>
  
  <p>Thanks a lot !</p>