Using Spring Boot, JPA, Hibernate Bidirectional Mapping Part 3 | CodeWithNaval

preview_player
Показать описание
In this tutorial we will build CRUD Operation Using Spring Boot, MySQL, JPA, Hibernate.
We will create RESTful APIs and then we test those APIs using Postman.

I have provide project in GitHub you can check on that.

guys I thing you learn something from this video. if you like and watch more video then LIKE, SHARE and SUBSCRIBE my Channel and become part of this Channel

Unidirectional :
-No Need To Define Mapping In Child Entity Classes.
-Only Parent Table Know About Mapping.

Bidirectional:-
-In Parent Entity Class And Child Entity Class Both Side
Define Mapping .

ex. Parent -- OneToMany
Child -- ManyToOne .

Mapping Type:-

1) @OneToOne
- One Parent Should Only One Child
- Child Also Have only one Parent
2) @ManyToOne
- -Many Parent Have One Child.
- One Child Have Many Parent.
3) @OneToMany
--One Parent Have Many Child.
- Many Child Have One Parent.
4) @ManyToMany
- Many Parent Have Mane Child.

Cascade Types in Hibernate
Cascading is a phenomenon involving one object propagating to other objects via a relationship. It is transitive in nature and the cascade attribute in hibernate defines the relationship between the entities. The cascading types supported by the hibernate framework are as follow:

CascadeType.PERSIST: It means that the save() and persist() operations in the hibernate cascade to the related entities
CascadeType.MERGE: It means that the related entities are joined when the owning entity is joined
CascadeType.REMOVE: It means that the related entities are deleted when the owning entity is deleted
CascadeType.DETACH: It detaches all the related entities if a manual detach occurs
CascadeType.REFRESH: It works similar to the refresh() operation in the hibernate
CascadeType.ALL: It is an alternative for performing all the above cascade operations in the hibernate framework

All Video Link

Рекомендации по теме
Комментарии
Автор

@20:24 thank you bro, i got stuck in these why reference entity is null.

AjayKumar-ocb
Автор

I have still issue about looping in service class while @OneToMany.

Selscript
Автор

Hi naval, I got the solution, there is json issue, we have to just put @JsonManagedReference in Main class and in mapped class put @JsonBackReference.

Selscript
Автор

Please fix bug about loop in last @ManyToMany, I have Shaw in video. Help us
anyway Thanks

Selscript
join shbcf.ru