So, I have an abstract class with subclasses that are concrete that is an @Entity, and Hibernate complains, Getter methods of lazy classes cannot be final
. All the other Entity classes seem ok with kotlin-jpa
. I thought perhaps it was the abstract
nature, so I made it non-abstract as a test, and I get the same result. It’s the only case of polymorphic inheritance I have in this Kotlin/JPA project, so maybe something there?
Anyone else have any theories for solutions short of marking all the getters as open (which is fine, I guess, but mildly annoying).
1 Like
I am using the allopen plugin. Noticed the same error as you.
I had explicitly marked the class as open. Removing the open
keyword from the class caused the error to go away.
My guess is that either the allopen plugin doesn’t do anything if the class is already marked as open, or hibernate is able to workaround kotlin classes that are not marked as open.
1 Like
My base class definitely isn’t marked open, although it is abstract
, and as the Kotlin docs suggest:
Note that we do not need to annotate an abstract class or function with open – it goes without saying.
So I think it’s effectively open, but the members are not unless I mark them as such, and allopen/jpa won’t do that because the class is effectively open?
Shouldn’t be too hard to check. Just look at the generated jar file with a decompiler. Based on the description of the all open plugin all members (even those of abstract classes) should be open. If not maybe you should create a youtrack issue for this. Either the description is wrong or this is just a bug.
1 Like