From the course: Building Java Microservices with gRPC

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Add database method to get orders

Add database method to get orders

From the course: Building Java Microservices with gRPC

Start my 1-month free trial

Add database method to get orders

- [Instructor] The next step will be to write the OrderDao class which is going to get us the orders for the user from the database. So let's go to the IDE, and under the db package, I will add one more class, which is the OrderDao. In this I will take a Logger first for logging anything, it's java.util.logging, and let's see Logger.getLogger orderDao.class.getName. So we have the logger ready, and then we can write a method which is going to retrieve the orders. So for this, we will first need a domain object in order to collect all the orders data. So let's go and do that first. I will go to the db package, make another class that will be Order, which is the domain object inside which all my data sits. Let's come back to the Order now and define fields in this, so there will be a private userId, there will be an orderId, there'll also be noOfItems, for every order, there will be the amount, and there'll be an…

Contents