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

Share
Embed
  • Published on Nov 10, 2020
  • 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/codeforgeyt/one-to...

    Follow //CodefForgeYT on:
    FB: codeforgeyt/
    Twitter: codeforgeyt
    GitHub: github.com/codeforgeyt
    Instagram: codeforgeyt

Comments • 39

  • Ovidiu S

    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.

  • Pavel N
    Pavel N  +2

    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!

  • aniket chavan

    Subscribed.

  • Vengatesh M

    Thank You very much.

  • Valdr Hugr

    Ś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

  • Marckhycs

    Thanks for this, very helpful to level up my understanding about springboot.

  • Purushotham V

    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?

  • Nianed David

    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?

  • Makix
    Makix  +2

    Clean, if I learn with you I will upgrade my skills fast. thank you very much

  • dimitris fou

    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 ??

  • Duc Nguyen

    You saved my day. Thank you very much

  • swapnil kumar

    Liked. Subscribed.

  • Ronald Steeven Pineda Portal

    Good tutorial dude!

  • Eduard-Alexandru Predescu

    It's a shame you have such a low ammount of views! Keep up the good work g!

  • Erick Jhorman Romero

    Why did you not use JpaRepository instead of Crud one?

  • nosk8
    nosk8  +1

    Goooooood job dude!

  • nosk8
    nosk8  +1

    : )

  • Pszemo
    Pszemo  +1

    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?