microservices-patterns / ftgo-application

Example code for the book Microservice patterns
Other
3.35k stars 1.29k forks source link

Q: JPA layer - is there might be a need to use @OneToMany, @ManyToOne, @ManyToMany? #123

Open asn25 opened 3 years ago

asn25 commented 3 years ago

Hi Chris,

I'm checking JPA layer of FTGO application. Could you please help me to clarify information on that. In a number of previously seen applications I've encountered intensive usage of @OneToMany, @ManyToOne, @ManyToMany (also with some following troubles and JPA Exceptions with Cascading problems on saving, especially for @ManyToMany).

In FTGO there are only:

Questions are: 1) Why there is this difference in annotation usage? Maybe, because @OneToMany/@ManyToOne/@ManyToMany are used on related Entities - and in FTGO there is a concept of Aggregate introduced (central Entity with surrounding Value objects)? 2) Is it possible situation in FTGO when you have to use @OneToMany/@ManyToOne/@ManyToMany as well? Or FTGO JPA layer can live and work with @Embedded annotation only?

Thanks!