Spring Boot pt. 4: Create mySQL Table, @Entity, @Repository

5 months ago
5

This episodes covers creating a new mySQL table, @Entity annotation in Java, mapping the Java Class to the mySQL table, creating the repository layer, injecting it into our controller and calling the repository findAll() and findById(int) methods.

SQL commands:

USE nobs;

CREATE TABLE product (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255)
description VARCHAR(255)
price DOUBLE,
quantity INT
);

INSERT INTO product (name, description, price, quantity)
VALUES
('Product 1', 'Description for Product 1', 10.99, 100),
('Product 2', 'Description for Product 2', 19.99, 50);

LinkTree:
https://linktr.ee/peachezprogramming

Loading comments...