This is a test project made to understand the implementation of:
Spring Data JPA
Some important points regarding spring data jpa:
- CascadeType is related to the persistence(saving), deletion i.e of database entities. It has nothing to do with the code.
- FetchType means loading data.
- LAZY: Don't load associated entity.
- default in
OneToOne
- default in
- EAGER: Load associated entity.
- default in
OneToMany
&ManyToMany
- default in
- LAZY: Don't load associated entity.
- Setting the
mappedBy
property will make the relationship bidirectional. - Unidirectional relationship causes join tables in the database except for
ManyToMany
. - Add
@JsonIgnore
on one of the linked entities to avoid recursion. - Add
@JoinColumn
on one of the linked entities to make it a foreign key.