Java Spring Boot - JPA - Hibernate - H2 - One To Many - REST Web Service - RESTful API

  Рет қаралды 29,407

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.
After creating relation we will create CRUD repositories for both of our entities, so we will be able to perform different database operations like persisting and retrieving.
When the implementation of the database communication layer will be ready we will implement service layer where we will implement main logic of our web service.
After that we will implement Rest Controllers which will expose endpoints to manipulate our entities. At the end we will do some small adjustments and we will add Swagger UI documentation to easily test our endpoints.
Step by step tutorial to get you started with service oriented approach. I hope guide will be useful for you. Keep coding!
Code for this video: github.com/cod...
Follow //CodefForgeYT on:
FB: / codeforgeyt
Twitter: / codeforgeyt
GitHub: github.com/cod...
Instagram: / codeforgeyt

Пікірлер: 50
@Jonsy
@Jonsy 2 жыл бұрын
This is EXACTLY what i was looking for. Thank you so much for this video. The way you explained every aspect and gave a reason for every decision, was very informative.
@aniketchavan8443
@aniketchavan8443 3 жыл бұрын
Subscribed. One of the best resources to reach out to follow cleaner implementation and industry practices. Keep the great work, looking forward for content on microservices.
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Wow, thanks for great feedback! Glad you like the content! Keep coding!
@elierantonioruedasulbara9562
@elierantonioruedasulbara9562 Жыл бұрын
Thank you man, I was looking like crazy how to make these relationships and thanks to you I achieved it, thank you very much, you helped me a lot. Greetings from Colombia.
@silentadvisor
@silentadvisor 3 жыл бұрын
Oh, man. This is the best video for creating REST app with JPA I found on youtube. Previously, what you have in this video, I found in parts. It is a pity that youtube did not offer this video earlier. Keep up the good work!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey! Thanks for awesome feedback, glad you like the content! Keep coding! :D
@vengateshm2122
@vengateshm2122 2 жыл бұрын
Thank You very much. Excellent JPA playlist. Easy to comprehend the underneath concept. Kudos to your effort!!!
@CodeForgeYT
@CodeForgeYT 2 жыл бұрын
Hey! Thanks for the feedback. Happy to hear that you like it!
@Fluttertrends
@Fluttertrends Жыл бұрын
Thanks a lot, Great tutorial!! All worked just not the Swagger then I used Postman and everything was alright!!!
@marckhycs319
@marckhycs319 3 жыл бұрын
Thanks for this, very helpful to level up my understanding about springboot.
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Awesome! Glad you like it
@swapnilkumar6852
@swapnilkumar6852 3 жыл бұрын
Liked. Subscribed. One of the best resources out there!!!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Glad you like it! Thanks!
@ramabookstroremalang9131
@ramabookstroremalang9131 2 жыл бұрын
Just Subscribed. This tutorial absolutely helps me!! Thank you... thank you!
@CodeForgeYT
@CodeForgeYT 2 жыл бұрын
Thanks for the sub!
@duccloud4101989
@duccloud4101989 3 жыл бұрын
You saved my day. Thank you very much
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey! Glad about it. Good rest of the day to you!
@thorbjorn1993
@thorbjorn1993 3 жыл бұрын
Świetne materiały! Szukałem takich tutków kupe czasu i w końcu znalazłem :) Po głosie od razu poznałem ,że z Polski :D
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey! Super, ciesze sie, ze Ci sie przydalo! No i dzieki, za pozytywny feedback, to chyba pierwszy komentarz po polsku! :D
@thorbjorn1993
@thorbjorn1993 3 жыл бұрын
@@CodeForgeYT Bardzo się przydaje , szczególnie że miałem wcześniej mnóstwo problemów żeby znaleźć jakiś wartościowy film o springu. Tutaj wytłumaczyłeś prosto jak chłopu więc w końcu do mnie dotarło ! :D Keep going, nice channel !
@AdamBekisz
@AdamBekisz 3 жыл бұрын
@@CodeForgeYT no to ode mnie drugi :) fajny materiał, chociaż straszny mętlik się robi z tymi dto. Jakie są zagrożenia jeśli bez nich? Poza tym czy PlainCardDto jest konieczne jeśli mamy możliwość skorzystania z @JsonManagedReference i @JsonBackReference? Czy może są jakieś przeciwskazania do ich używania?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
@Adam Bekisz Hey! Wielkie dzieki! Zagrozenia sa takie, ze bez nich w przypadku relacji dwukierunkowych przy serializacji jackson sie zapetli. Jesli nie chcesz stosowac DTO to spokojnie mozesz zastapic go encja z tymi wlasnie anotacjami. W zaleznosci od potrzeb mozna stosowac jedno lub drugie podejscie. DTO moim zdaniem jest o tyle fajne ze jest bardziej elastyczne w niektorych przypadkach, np. gdy potrzebujesz splaszczyc jakis obiekt. Proces mapowania DTO na encje i w druga strone mozna uproscic za pomoca biblioteczki mapstruct. Planuje w przyszlosci przygotowac wideo jak z niej korzysta. Pozdrawiam! Keep coding!
@mikseros123
@mikseros123 2 жыл бұрын
A jednak! A ja myślałem, że jakaś Albania/Rumunia.
@rhaelhenrique
@rhaelhenrique Жыл бұрын
Thank you very much. Your video helped me a lot.
@eduard-alexandrupredescu6982
@eduard-alexandrupredescu6982 3 жыл бұрын
It's a shame you have such a low ammount of views! Keep up the good work g!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Thanks, will do!
@ovidius781
@ovidius781 3 жыл бұрын
Be careful with Data annotation from Lombok when you use it on entity, because it generate hash code and equals different than hash code used on jpa and can appear missunders when you want to use detached entities.
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey! Thanks for sharing the knowledge, hope it will be useful for someone. Keep Coding!
@asdfasdfasdfasdf219
@asdfasdfasdfasdf219 3 жыл бұрын
Good tutorial dude!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Thanks!
@jacksonnosk8112
@jacksonnosk8112 3 жыл бұрын
Goooooood job dude!
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Thanks!
@konstantinchvilyov9602
@konstantinchvilyov9602 Жыл бұрын
Thank you! Very easy and helpful for my preparing to interview in English. Your pronunciation is very understandable for me. But your "generated" word pronunciation surprised me a little. It is close to my pronunciation of this word in Russian. Is English your native language?
@tunebaker
@tunebaker 10 ай бұрын
As I think the author is from Poland, that's why his pronounciation is MUCH clearer than for example most of indian guys )) BTW great tutorial, thanks a lot!
@purushothamv5883
@purushothamv5883 3 жыл бұрын
The way your created DTO is simple and awesome, Great, Thanks, keep up the good work. But can we have such methods on our entities, is it a good practice?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Hey! Great question. I think it is not considered a bad practice, but I think it would be better to have a mapper classes for entities where you can put mapper methods for each conversion. Alternative is to use library like mapstruct where you have to define interface and it will generate mappers for you, but it has its own pitfalls. Hope it helps. Keep coding!
@purushothamv5883
@purushothamv5883 3 жыл бұрын
Sure, got it...Thanks for the reply
@Sulacv2
@Sulacv2 2 жыл бұрын
Hey here, i've trouble on the CartService.java at 1:10:15 , My problem is the getCart method appear in red with the message " Cannot resolve method getCart() " I don't understand wher's my problem, everything before work fine
@dimitrisfou6908
@dimitrisfou6908 3 жыл бұрын
your video is very helpful and congratulations for that, but why y don't define the deleteItem() like a void and delete the Item by deleteById(id) method ??
@nianeddavid7985
@nianeddavid7985 3 жыл бұрын
the best course I have taken regarding spring. But I would like to know is it possible to directly assign a card to a tag without going through the controller?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Glad you like it! What you mean by assinging card to a tag and by directly?
@nishantpatial2611
@nishantpatial2611 2 жыл бұрын
Hi sir, for me removeItemFromCart() is not functioning. It is not deleting the item from cart no change in the cart items plz help.
@Pszemo
@Pszemo 3 жыл бұрын
Jak to jest w koncu z tym DTO? Powinienem to stosowac zawsze, jesli nie to w jakich sytuacjach. Czy jezeli obiekt Dto ma w zasadzie takie same pola jak nasza encja nie moge po prostu wystawic naszej encji? Mozesz mi jeszcze raz wytlumaczyc po co zostal stworzony PlainCartDto? Nie dalo sie tego inaczej zrobic? Dodatkowe pytanie odnosnie ResponseEntity, w wielu poradnikach zwracany jest obiekt np Student, zgaduje ze raczej powinnismy korzystan z ResponeEntity by wyslac jeszcze dodatkowo poprawny status odpowiedzi? Pozdrawiam
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Jesli chodzi o response entity to tak, lepiej obiekt opakowac niz wysylac go w surowej postaci. Nie trzeba robic Dto mozna zastosowac @JsonManagedReference, @JsonBackReference dla relacji dwukierunkowych. Generalnie jesli nie widzisz potrzeby hermetyzacji parametrow obiektow w dto, lub nie potrzebujesz innych parametrow w obiekcie niz te ktore sa w encji to spokojnie mozesz ich uzyc. Ja preferuje uzywanie dto.
@erickjhormanromero6905
@erickjhormanromero6905 3 жыл бұрын
Why did you not use JpaRepository instead of Crud one?
@CodeForgeYT
@CodeForgeYT 3 жыл бұрын
Well, JpaRepository is the most complex one and it allows for operations on persistance context (it extends CrudRepository). Simply it wasn't necessary to use it here. We needed only CRUD operations so CrudRepository was good enough. Hope it helps. Keep coding!
@erickjhormanromero6905
@erickjhormanromero6905 3 жыл бұрын
@@CodeForgeYT Good point thanks keep coding too
@jacksonnosk8112
@jacksonnosk8112 3 жыл бұрын
: )
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 13 МЛН
إخفاء الطعام سرًا تحت الطاولة للتناول لاحقًا 😏🍽️
00:28
حرف إبداعية للمنزل في 5 دقائق
Рет қаралды 49 МЛН
小路飞嫁祸姐姐搞破坏 #路飞#海贼王
00:45
路飞与唐舞桐
Рет қаралды 20 МЛН
Hibernate & JPA Tutorial - Crash Course
24:27
Marco Codes
Рет қаралды 103 М.
Spring Boot Tutorial - Crash Course
1:16:32
Marco Codes
Рет қаралды 158 М.
The Value of Source Code
17:46
Philomatics
Рет қаралды 67 М.
OYUNCAK MİKROFON İLE TRAFİK LAMBASINI DEĞİŞTİRDİ 😱
00:17
Melih Taşçı
Рет қаралды 13 МЛН