I have a REST API that will receive some customer data on the following format:
{
    "customer_Id": 50,
    "name": "name",
    "company_name": "company_name",
    "email": "email@provider.com",
    "business_phone": "(00) 1111-2222",
    "mobile_phone": "(00) 1111-2222",
    "document": "123456789",
    "state_registration_number": "ISENTO",
    "state_registration_type": "NO_CONTRIBUTOR",
    "city_registration_number": "ISENTO",
    "classification": "AUTO",
    "address": {
        "street": "STREET NAME XXX",
        "number": "NUMBER XX",
        "complement": "COMPLEMENT",
        "zip_code": "ZIP_CODE",
        "neighborhood": "NEIGHBORHOOD",
        "city": "CITY",
        "state": "STATE"
    }
}
I'd like to save this data on two tables: One table should contains the "main" customer data, and the other one should contais the customer's "address" data.
So, I defined the Customer entity as below:
@Data
@Entity(name = "X_CUSTOMERS")
public class Customer {
    @Id
    private int customer_Id;
    @NotNull
    private String name;
    private String company_name;
    private String email;
    private String business_phone;
    private String mobile_phone;
    @NotNull
    private String document;
    private String state_registration_number;
    private String state_registration_type;
    private String city_registration_number;
    @NotNull
    private String classification;
    @OneToOne(cascade = CascadeType.ALL)
    private Address address;
}
And the Address entity as
@Data
@Entity(name = "X_ADDRESS")
public class Address {
    @NotNull
    private String street;
    private String number;
    private String complement;
    private String zip_code;
    private String neighborhood;
    private String city;
    private String state;
}
But, I couldn't realize how to create a relationship between them. Should I create a customer_id attribute on the Address entity? Should I define some additional Tags on Customer's address attribute? Note that I don't have a customer on the JSON data that is posted by the REST Client and, if a Customer is Update ou Deleted, the Address data should be Updated / Deleted also.
Sorry if this is a such trivial question. I'm learning the basics of JPA/Hibernate these days and your answer will guides me to the right direction to avoid things such 'reinventing the wheel'.
Thanks a lot!
 
     
    