Spring Boot pt. 23: Relational Mappings @OneToOne (1/3)

7 months ago
5

SQL Queries:
CREATE TABLE address (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
street VARCHAR(255),
city VARCHAR(255),
state VARCHAR(255)
);

CREATE TABLE customer (
id BIGINT PRIMARY KEY AUTO_INCREMENT,
first_name VARCHAR(255),
last_name VARCHAR(255),
address_id BIGINT,
FOREIGN KEY (address_id) REFERENCES address(id)
);

INSERT INTO address (street, city, state) VALUES ('123 Main St', 'Cityville', 'CA');

INSERT INTO customer (first_name, last_name, address_id) VALUES ('John', 'Doe', 1);

In today's episode of the No BS Java Spring Boot Guide, we cover relational mappings for relational databases and use the @OneToOne annotation and cascade = CascadeType.ALL
@JoinColumn

Loading comments...