Java Spring Boot - JPA - Hibernate - H2 - One To Many Bidirectional Relationship - @OneToMany

  Рет қаралды 41,632

CodeForgeYT

CodeForgeYT

Күн бұрын

In this video we will implement one to many bidirectional relationship using Java, Spring Boot, JPA, Hibernate and H2 in memory database. We will start with generating project and adding all of the necessary dependencies. Later on we will create entities and then we will create a one to many relationship between them using @OneToMany and @ManyToOne annotations. We will persist example data in database using CRUD repositories to test out if our mapping works correctly. Later we will test out if our operations are cascaded to the associtated entities and if the orphan removal attribue is working correctly for the entities that depends on each other. We will track everything using H2 console. Everything with in-depth explanation! Keep playing with code!
Follow //CodefForgeYT on:
FB: / codeforgeyt
Twitter: / codeforgeyt
GitHub: github.com/cod...
Instagram: / codeforgeyt

Пікірлер: 41
@AshishYadav-zw1vr
@AshishYadav-zw1vr 4 ай бұрын
best JPA tutorial. Thank you for vedio.
@801yaoichan
@801yaoichan 3 жыл бұрын
The best tutorial, this solved all my problems!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Awesome! Keep coding!
@drupalguy
@drupalguy 3 жыл бұрын
Just what I was looking for after much struggle. Thank you for the video
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
You are welcome!
@mamilosrosados
@mamilosrosados 4 жыл бұрын
Thanks man. I had some problems with relationships and everything is working now
@CodeForgeYT
@CodeForgeYT 4 жыл бұрын
Glad it works!
@dominicencho4179
@dominicencho4179 3 жыл бұрын
Thanks so much for this video. I have been looking for this
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
You are welcome!
@patrikhyll4301
@patrikhyll4301 2 жыл бұрын
Great tutorial, explained very well!
@CodeForgeYT
@CodeForgeYT 2 жыл бұрын
Awesome! Glad you like it!
@michaelmihov1651
@michaelmihov1651 3 жыл бұрын
So precise , thanks ! :)
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Glad you like it!
@kevinlapus7624
@kevinlapus7624 Жыл бұрын
Thank you Teacher Love lots
@gauravbisht516
@gauravbisht516 Жыл бұрын
It worked. Thanks!!!!
@bartoszj.9050
@bartoszj.9050 2 жыл бұрын
Thanks, great tut
@CodeForgeYT
@CodeForgeYT 2 жыл бұрын
Glad it was helpful!
@gauravswain6907
@gauravswain6907 4 жыл бұрын
thanks for the video man, i got here after quite a struggle. request you to share video on same concept but in mongodb !
@CodeForgeYT
@CodeForgeYT 4 жыл бұрын
Hey! I am happy that video helped you! Yeah MongoDB is quite popular so video about it sounds like great idea. Thanks for feedback. Happy coding!
@anthonyvertigo552
@anthonyvertigo552 3 жыл бұрын
Very good tutorial! Thank you :) btw where are you from ?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey, you are welcome, pl
@anthonyvertigo552
@anthonyvertigo552 3 жыл бұрын
@@CodeForgeYT I thought that. Keep doing that good job!. Thanks again for the tut :)
@canaldopericles2167
@canaldopericles2167 2 жыл бұрын
thanks
@Das.Kleine.Krokodil
@Das.Kleine.Krokodil Жыл бұрын
Do I understand correctly that if there are two entities with a One-to-Many relationship, such as Employee and EmployeePhones. Then you need to receive such data on the server in DTO with one call, but with two separate json? And write down one by one: first the employee, get the ID from the saved employee, and then we record the phones using this ID for communication.
@RN-jo8zt
@RN-jo8zt 2 жыл бұрын
Any one can please explain me what does it mean? bidirectional relationship provides navigational access in both directions, so that you can access the other side without explicit queries.
@sajanah1253
@sajanah1253 4 жыл бұрын
Hey man. Thanks a lot for this. Also would you mind making another video doing this with a web app? I mean create a cart, adding items and delete ect..
@CodeForgeYT
@CodeForgeYT 4 жыл бұрын
I want to make few videos about react so, I will take this into account. Thx for feedback!
@sajanah1253
@sajanah1253 4 жыл бұрын
@@CodeForgeYT Awesome. Love the simple and short videos man.
@CodeForgeYT
@CodeForgeYT 4 жыл бұрын
Glad to hear that ; D
@alexandrutudoran3941
@alexandrutudoran3941 3 жыл бұрын
Why are you calling the ArrayList constructor in the Cart Entity?
@itzmeash1
@itzmeash1 2 жыл бұрын
Great example, but i am getting null value in my foriegn key mapping in child table, i am expecting primary key of cart to come in the child table, but its just NULL , can you advise, what could have gone wrong . Thanks
@dariagrigoruk3684
@dariagrigoruk3684 Жыл бұрын
because he gave you wrong information! It's bad tutorial
@Mandih7225
@Mandih7225 3 жыл бұрын
Any tips on how to convert from OneToMany to ManyToMany relationship using Spring, Hibernate, and JPA?
@Mandih7225
@Mandih7225 3 жыл бұрын
I am aware there is a @ManyToMany annotation in Spring, but what needs to happen after changing the annotation?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
@@Mandih7225 Check out my tutorial about Many to Many. From the code point of view you have to change your entities that are part of the relation and of course you have to change the annotation. From database perspective it depends. If it is empty you just have to create a new db structure generated by jpa. If you already have some data in the db you have to prepare migration scripts so you can migrate data to new structure
@Mandih7225
@Mandih7225 3 жыл бұрын
@@CodeForgeYT will do! Thanks!
@senthilmurugangsm
@senthilmurugangsm 3 жыл бұрын
Is it mandate to set parent in child objects?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
I think it is for bidirectional relationship
@senthilmurugangsm
@senthilmurugangsm 3 жыл бұрын
@@CodeForgeYTyup, it's bidirectional. if we are not set, then null is inserted in the child entries.
@itzmeash1
@itzmeash1 2 жыл бұрын
@@senthilmurugangsm Hi Senthil , i followed the example shown in the tutorial , but i am getting NULL value as my forign key in child table, can you advise what could have been wrong . Thanks
@dariagrigoruk3684
@dariagrigoruk3684 Жыл бұрын
Many things doesn't work on my sample. Like the @JoinColumn( name="cart_id",..) it should be the same name as the primary Key in the class Cart "id"
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 123 МЛН
РОДИТЕЛИ НА ШКОЛЬНОМ ПРАЗДНИКЕ
01:00
SIDELNIKOVVV
Рет қаралды 3,2 МЛН
Spongebob ate Patrick 😱 #meme #spongebob #gmod
00:15
Mr. LoLo
Рет қаралды 21 МЛН
Миллионер | 1 - серия
34:31
Million Show
Рет қаралды 2,3 МЛН
JPA / Hibernate One to Many Mapping Example with Spring Boot
20:02
Running With Bigger And Bigger Lunchlys
00:18
MrBeast
Рет қаралды 123 МЛН