课程: Learning JDBC

免费学习该课程!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Implement a DAO

Solution: Implement a DAO

(upbeat music) - [Instructor] So now it's time for my solution to this challenge exercise. So I started by creating an entity called Customer. And in this entity, I have the six fields that are represented by the database table, a customer ID of type UUID, and then five strings, first name, last name, email, phone, and address. Now, technically, email is a unique field. So, we can take that into account when we build our DAO if we choose to. So let's go take a look at the customer DAO itself. So we have a GET_ALL, a GET_ONE, a CREATE, an UPDATE, and a DELETE. Again, if you wanted to add a GET_ONE by email address, you could have done that. I chose not to. The operations look very similar to what we did for the service. So we have a create, a delete, a getAll, a getOne, an update, and then the processResultsSet like we did before. So now if you go into your app, I've added into this all of the data for customers. So if I run this, and I expand my window here a little bit, you'll see…

内容