Open demkom58 opened 1 year ago
In general I like the idea. It should be easy to implement and might reduce a bunch of boilerplate. Something similar was also requested in #2364.
Feedback:
thank you, @Rawi01 ! i have started to implement it, so the pull request will be created pretty soon, depending on my free time
also i created the post on the Forum about this feature - https://groups.google.com/g/project-lombok/c/Z8LQEatEa-0
Describe the feature
The basic idea is to automate the generation of mutators for bidirectional object associations to eliminate error-prone code that is responsible about synchronization of both sides.
Examples
I haven't tested the code to see if it works, but the idea should be clear.
OneToOne
Source
Lomboked
OneToMany
Source
Lomboked
ManyToMany
Source
Lomboked
Describe the target audience
In almost any application that uses JPA are also used bidirectional associations, to synchronize both sides a lot of code should be written and maintained, this is the place where Lombok can help much and reduce count of error-prone code.
In the examples I have used Jetbrains Annotations for @ApiStatus.Internal and @UnmodifiableView. Also JPA annotations, which are located in jakarta.persistence.
Additional context
Reference: https://vladmihalcea.com/jpa-hibernate-synchronize-bidirectional-entity-associations/