简体   繁体   中英

lombok builder creating issue with hibernate list

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM