Reputation: 1271
I have a class lets say A. It has few non-null parameters. I am using lombok @NonNull and lombok @Builder. From documentation seems like Builder generates the not null check for parameters.
The other side of story is while retrieving A from DB using hibernate list it is throwing exception saying that A is missing no-arg constructor.
I have no idea on this. I have not defined any constructor for A except for @builder and @NonNUll checks for few parameters. Any idea whats going wrong?
Upvotes: 1
Views: 913
Reputation: 1271
I found solution. Though it seems like a work around. Adding @NoArgsConstructor @AllArgsConstructor and @builder seems good. Hibernate and builder both can happily work toegther with this
Upvotes: 2
Reputation: 1508
Add the @NoArgsContructor
to your class.
Hibernate uses this constructor and then sets the properties.
When you're using @Builder
, i think Lombok is generating a constructor that is not the no args one.
Upvotes: 1