---
# System prepended metadata

title: 3Building your First RESTful CRUD API.

---

# 3Building your First RESTful CRUD API.
## Part 3: Creating the Reservation Domain / Model Object
Domain / Model objects are objects that are specific to your service (also known as **Data Transfer Objects (DTO's)**) and can be passed around the application.

### Wait... DTO's sound a lot like DAO's... What's the difference?🤔
A **DTO** is used to transfer the data ***between*** classes and modules of your application. A DTO will **NOT** interact with a database at all.

A **DAO** is a Data Access Object layer e.g. `ReservationEntity` and `ReservationRepository`. This layer is responsbile for interacting with the database and doing nothing else.

With that in mind, if you have a DTO that needs to be stored in a database, you will need to map the DTO into a DAO and this DAO will be persisted into the database.
Your DAO may contain additional metadata about the record that needs to be stored e.g. the `createdDate` of the record. This is stuff that the DTO may not care about, but may be useful for other teams that may perform analysis on the database records. 

### Implementing the Reservation model object.
1. Create a new package called `model` within  `com.rms.reservationservice`. 
2. Create a class called `Reservation`. Within this class we can represent what our reservation model will look like.

```
package com.rms.reservationservice.model;

import lombok.Builder;
import lombok.Data;
import java.time.LocalDateTime;

@Data
@Builder(toBuilder = true)
public class Reservation {

    private String id;

    private String firstName;
    private String lastName;
    private LocalDateTime reservationTime;
    private int numberOfGuests;
    private int duration;
}
```
- ***@Data*** - Provides toString, equals and hashCode, getters and setters methods for our class. (see more [here](https://projectlombok.org/features/Data))
- ***@Builder*** - Utilises the Builder design pattern to create immutable objects. (see more [here](https://projectlombok.org/features/Builder))
    - ***toBuilder=true*** -  creates a new builder that starts out with all the values of this instance so that you can insert any missing elements without modifiying the original object, maintaining object immutability.
    - This will become quite useful later on down the line, just keep reading and you will see 😄

If you did get stuck at any point, please checkout the branch [part-3-creating-the-reservation-model](https://github.com/csapty12/restaurantManagementSystem/tree/part-3-creating-the-reservation-model) and compare your code against mine.

🎉 **Waheyy! We are now half way to creating our RESTful CRUD API! 🎉**. Wow, that really has not taken long to complete.
As we have the Reservation DTO created, we can now move onto creating the service layer which is where all the business magic happens 😉. Checkout [Part 4: Creating the Reservation Service Layer]() to see how we can start including some business logic within our application!