2023-03-21

Spring Data JPA

PostgreSQL tips: https://www.youtube.com/watch?v=9SGDpanrc8U&t=2273s

Postgres & docker compose https://youtu.be/-mwpoE0x0JQ?t=3943

https://github.com/amigoscode/microservices/blob/main/docker-compose.yml

docker compose up -d

docker compose ps

docker logs postgres -f

postgres https://youtu.be/p485kUNpPvE?list=PLwvrYc43l1Mwqpf9i-1B1gXfMeHOm6DeY&t=2438

https://github.com/amigoscode/spring-boot-fullstack-professional/blob/6-spring-data-jpa/src/main/resources/application.properties

spring.datasource.url=jdbc:postgresql://localhost:5432/amigoscode

spring.datasource.username=postgres

spring.datasource.password=password

spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

spring.jpa.properties.hibernate.format_sql=true

> docker exec -it postgres bash

psql -U amigoscode

\l  (to list databases)

CREATE DATABASE customer;

CTRL+D

CTRL+D

####

@Id

@SequenceGenerator(

        name = "customer_id_sequence",

        sequenceName = "customer_id_sequence",

        allocationSize = 1

)

@GeneratedValue(

        strategy = GenerationType.SEQUENCE,

        generator = "customer_id_sequence"

)

private Integer id;

##############################

\c customer (connect to db customer)

\dt (list of relations)

\d (list of relations)

\d customer (see table structure)

##########################

Mongo:

Developing with Docker - Docker in Practice || Docker Tutorial 8 https://youtu.be/6YisG2GcXaw?list=PLy7NrYWoggjwPggqtFsI_zMAwvG0SqYCb&t=231

Docker commands: https://gitlab.com/nanuchi/techworld-js-docker-demo-app/-/blob/master/README.md

https://gitlab.com/nanuchi/techworld-js-docker-demo-app/-/blob/master/docker-compose.yaml

https://gitlab.com/nanuchi/techworld-js-docker-demo-app/-/blob/master/Dockerfile

#################################

h2db

spring.h2.console.enabled=true

spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1

spring.datasource.username=sa

spring.datasource.password=

spring.datasource.driver-class-name=org.h2.Driver

spring.jpa.hibernate.ddl-auto=create-drop

spring.jpa.show-sql=true

#spring.jpa.properties.hibernate.format_sql=true


https://youtu.be/5yquJa2x3Ko?t=759 Mapper as Function


No comments: