Using @Builder annotation with JPA Entity classes and compatibility issues with @AllArgsConstructor: What are the best solutions?

152 views
Skip to first unread message

J

unread,
Mar 31, 2023, 4:23:01 PM3/31/23
to Project Lombok
I have read some articles about compatibility issues when using the @AllArgsConstructor annotation in JPA Entity classes. The problem is that I would like to use the @Builder annotation for my Entity class, but if I use it, @AllArgsConstructor will be created automatically. Should I manually create the Builder pattern to avoid this problem?
If you have any good solutions to this issue, please let me know. 
Additionally, if I have misunderstood the concept, please kindly correct me. 

Thank you!

Jan Materne

unread,
Apr 1, 2023, 2:05:55 AM4/1/23
to project...@googlegroups.com

I use:


@Builder
@AllArgsConstructor
@NoArgConstructor
@Entity
public class MyEntity ...



Jan

--
You received this message because you are subscribed to the Google Groups "Project Lombok" group.
To unsubscribe from this group and stop receiving emails from it, send an email to project-lombo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/project-lombok/a298da45-3c75-4e89-a9fd-09137c214968n%40googlegroups.com.

Mat Jaggard

unread,
Apr 2, 2023, 5:03:04 AM4/2/23
to project-lombok
What's the actual problem? We use @AllArgsConstructor and @Builder with JPA.

If you do have issues you can also apply @Builder to a manually written constructor.

Many thanks,
Mat.

--
Reply all
Reply to author
Forward
0 new messages