title: Kotlin inheritance and JPA
body: <p>I'm trying to implement inheritance with Kotlin and JPA. My abstract base class (annotated with <code>@Entity</code>) holds the ID (annotated with <code>@Id</code> and <code>@GeneratedValue</code>) and other metadata, like createDate, etc. I'm getting several errors from Hibernate, one for each field except the ID:</p>
  
  <blockquote>
    <p>org.hibernate.tuple.entity.PojoEntityTuplizer - HHH000112: Getters of lazy classes cannot be final: com.example.BaseEntity.createDate </p>
  </blockquote>
  
  <p>As I've read I need to include the open keyword for each property.</p>
  
  <p>I have 3 questions regarding this:</p>
  
  <ol>
  <li>Why do I have to do that in the superclass, and don't need in subclass? I'm not overriding those properties.</li>
  <li>Why isn't it complaining about the ID?</li>
  <li>It seems to work without the open keyword, then why is the error logged?</li>
  </ol>
  
  <p>Edit:</p>
  
  <pre><code>@Entity
  @Inheritance(strategy = InheritanceType.JOINED)
  abstract class BaseEntity(
      @Id @GeneratedValue(strategy = GenerationType.IDENTITY) val id: Long = 0,
      val createdAt: Instant = Instant.now()
  )
  
  @Entity
  class SubClass(
      val someProperty: String = ""
  ) : BaseEntity()
  </code></pre>
  
  <p>I'm using the JPA plugin for Gradle, which I believe creates the noarg constructor, that's why I don't have to specify everything nullable.</p>
  
  <p>Thank you!</p>