How to place annotation on getter?


I'm trying to give Kotlin a try in real life and make small project with Spring and JPA/Hibernate.

I have a lot of things which are not null in database, but are not known at time object is created. So again Delegates.notNull() is the answer. But I’ll have to use property access mode in JPA (delegated property is private ReadWriteProperty in bytecode) and so I need to place all annotations (like this Column or NotNull) on getters of properties where I need such.

Simpler question how to place annotation on getter on simple property is also actual.


Found simple case,   private var id: Int? = null   [Id]   get() = $id

seems to compile what needed, at least according to jd. But in case of delegated property there is no $property and Kotlin: Delegated property cannot have accessor

So question is really about delegated properties.


This seems to be a bug. I have reported it to the tracker: Please vote for it to receive notifications