I use project lombok and Hibernate
together.
I'm wondering which lombok annotation should be generally used on entity classes.
First candidate is @Data
but it generates setters for all non-final fields. Since id
field is not final I have setId()
method which I don't want.
The second candidate is @Value
but then id
field is marked as final and that's why it has to be manually assigned by an application.
I could also use @Builder
but it has the same issue as @Data.
To solve problem with @Data
I can write my own private setter for id
field to override generated one. But maybe there is a better way? What is the best practice in this case?