The DAO Pattern in Java | Data Access Object Design Pattern

Поділитися
Вставка
  • Опубліковано 1 лис 2024

КОМЕНТАРІ • 26

  • @jagotiberan2181
    @jagotiberan2181 Рік тому +1

    You explained in 10 minutes better than what took me more than a week to get my mind around in my classes. Thank you!

  • @guilhermelaviola8079
    @guilhermelaviola8079 3 роки тому +8

    Thank you so much, man! In only 12 minutes you managed to explain perfectly what my professor at school was unable to make me understand in a whole semester!

  • @abdulazeez.98
    @abdulazeez.98 Рік тому

    Finally a video which shows some code.
    Thanks

  • @PiyushSingh-em5vz
    @PiyushSingh-em5vz 4 роки тому +1

    You are great, mind blowing, fantastic, Amazing Java Developer

  • @javatechnology24
    @javatechnology24 4 роки тому +4

    As always again unique and informative video tutorial.

  • @emanuele9684
    @emanuele9684 2 роки тому +1

    if I have a second Dao class, I have to replicate the function getConnection()and all the constants (url user ecc) in the new class??

  • @christianlisangola9383
    @christianlisangola9383 3 роки тому +2

    But for the connection to the database you could have used a separate Singleton and for your DAOs, imagine that you have several classes that will perform actions like getAll, getById, etc... so instead you can create a generic interface for the basic CRUD operations which the DAOs of the specific domains will then implement and redefine the methods.

  • @thonglevan4950
    @thonglevan4950 4 роки тому +3

    Grateful to your sharing. I am stuck with the difference between DAO and Repository pattern. Please answer my question.

  • @wpatyune1631
    @wpatyune1631 4 роки тому +1

    Why your tutorial in your website doesn't show Service clasS?

  • @saktagan28
    @saktagan28 3 роки тому +2

    Github repository not contain all code, may you plz reload your code

  • @rwzaki
    @rwzaki 2 роки тому +1

    Thanks for this amazing video. I understood a lot from this video alone. But may I know why the service class/layer is not in the github repository? Is it intentional that there is no need for it since as you said in the video that so far there is no business logic? Also, can I know what is meant by business logic (an example will help me to grasp it)?

  • @illyatkachov4514
    @illyatkachov4514 2 роки тому

    Thanks man, good job

  • @irianicet
    @irianicet 2 роки тому

    Thank you a lot for this tutorial video which is very clear and helpful. However, I'd like to know how to design a DAO for a table which has one or more foreign keys. Thank you in advance.

  • @xxapoloxx
    @xxapoloxx 4 роки тому

    I have a question, in 4:26 your model layer class is User, but your service does not create a user object through something like "new user(id)", instead it goes to the DAO object, bypassing the model layer. Im looking for a pattern so that my service layer talks to and only to the model layer. Any tips?.

    • @JavaGuides
      @JavaGuides  4 роки тому

      Pass request data to service layer then create User object with request data in service layer itself. You have to call Dao class to store User object data into Database. Servlet depends on service layer and service layer depends on Dao layer. Dao pattern is to separate out database related logic from business logic as separate layer.

  • @nilaypaul9810
    @nilaypaul9810 2 роки тому

    Can someone tell me under which topic in Java this sub-topic falls?

    • @ppg3530
      @ppg3530 Рік тому

      Design pattern

  • @Endarire
    @Endarire 3 роки тому +1

    Speak much more loudly (about double the input volume), more clearly, and at about 75% your speed so I can better understand you.
    Thankee!

  • @anastasiosarvanitis9533
    @anastasiosarvanitis9533 3 роки тому

    Thank you so much for your video! But what happens when we want to implement a many to many relationship? Do we need a class to represent the linking table of the database? With spring and hibernate it's easy but how do we do it in jdbc? Do oyou have a relative article? Anyway you have done a great job and I thank you again!

    • @AndiRadyKurniawan
      @AndiRadyKurniawan 3 роки тому

      I think you can just fetch the records separately by the primary key and you might need to make multiple DAOs to share the same connections, use DAO Factory pattern for this I guess.
      E.g:
      List employees = daoFactory.getEmployeeDao().findAll(EmployeeFilter.ids(empIds));
      Set depIds = employees.stream().map(Employee::getDepartmentId).collect(Collectors.toSet);
      Map departments = daoFactory.getDepartmentDao().findAll(DepartmentFilter.ids(depIds)).stream().collect(Collectors.toUnmodifiableMap(Department::getId, d -> d));
      // Get the department name of an employee
      departments.get(employees.get(0).getDepartmentId()).getName();
      // or
      employees.stream().map(e -> departments.get(e.getDepartmentId()).map(Department::getName).findFirst().orElse(null);

  • @anoopsumbria8101
    @anoopsumbria8101 4 роки тому

    share the code

    • @JavaGuides
      @JavaGuides  4 роки тому

      The GitHub repository link given in a video description.

  • @nareshgaur4961
    @nareshgaur4961 4 роки тому

    Speak Loud Bro..

  • @vishnubj826
    @vishnubj826 Рік тому

    Pls speake louder...we can't hear u