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!
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.
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)?
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.
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?.
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.
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!
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);
You explained in 10 minutes better than what took me more than a week to get my mind around in my classes. Thank you!
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!
Finally a video which shows some code.
Thanks
You are great, mind blowing, fantastic, Amazing Java Developer
As always again unique and informative video tutorial.
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??
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.
Grateful to your sharing. I am stuck with the difference between DAO and Repository pattern. Please answer my question.
Thông Lê Văn same here
Stuck there
Why your tutorial in your website doesn't show Service clasS?
Github repository not contain all code, may you plz reload your code
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)?
Thanks man, good job
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.
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?.
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.
Can someone tell me under which topic in Java this sub-topic falls?
Design pattern
Speak much more loudly (about double the input volume), more clearly, and at about 75% your speed so I can better understand you.
Thankee!
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!
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);
share the code
The GitHub repository link given in a video description.
Speak Loud Bro..
Pls speake louder...we can't hear u