Constructor and Hibernate

In my entity, I initialize some fields in a constructor. (with plugins, this class has a no-args constructor and the class and all members are open using jpa plugin and all-open)

@Entity
class Bike {

    @Id
    val id: String

    var available: Boolean
        protected set

    @Suppress("ConvertSecondaryConstructorToPrimary", "LeakingThis")
    constructor(id: String) {
        this.id = id
        this.available = true
    }
}

If I disable all-open for this class, Hibernate demands that my properties are open, so it can inject some proxies for lazy initialization (prints ERROR log).
Turns out, I am assigning a value to open property in a constructor, which gives me an IDE warning.
I tried to research on that and I just can’t possibly find any issue with properties. Can you give me an example? I saw the example from an IDE when you call a method in a base class that uses a property from a child, but that’s not about properties.
In the Kotlin Hibernate tutorials (like Hibernate with Kotlin - powered by Spring Boot - Kotlin Expertise Blog) they just use primary constructors, but that is exactly the same thing, I don’t even understand why the warning goes away. In my code, I use secondary constructor just because it is easier to place annotations on the constructor, but I can just make it primary and it goes away.

Right now I am ignoring this warning, I think Hibernate won’t be doing any bad stuff with my properties since it’s all just proxies.

Please, let me know what you think, thanks!

First of all, you should use compiler plugin, so your entity classes will be open automatically. I’m using the following plugins block in my project:

plugins {
    id "war"
    id "org.jetbrains.kotlin.jvm" version "1.3.31"
    id "org.jetbrains.kotlin.plugin.jpa" version "1.3.31"
    id "org.jetbrains.kotlin.plugin.spring" version "1.3.31"
}

My Entity classes are quite simple:

@Entity
class Account(
        @Id
        val id: Long,

        val login: String,

        val password: String,

        @Enumerated(STRING)
        val type: AccountType,

        val lastname: String,

        val name: String,

        val fathername: String?
)

This setup works fine for me.

Thanks for your reply!
If you use a secondary constructor to, say, initialize id and login, will IDE warn you with accessing non-final property?
I’ve included a code sample into the post