Entradas

Mostrando entradas de mayo, 2023

SpringBoot (6) Spring Data JPA (1)

 1. application.yml This file is in the folder src/main/resources 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 spring: #--JPA datasource: #--Connection Pool hiraki: connectionTimeout: 20000 maximumPoolSize: 5 # PostgreSQL url: jdbc:postgresql://localhost:5432/mydb driver-class-name: org.postgresql.Driver username: user password: password jpa: hibernate: ddl-auto: update show-sql: true This will create or update tables 2. Defining Entities to persist There are many entries where defining entities but an Entity needs: The @Entity annotation The@Audited annotation if you want a control version The @Table (name="table_name",  schema = "myschema", uniqueConstraints..., indexes ..) All the related entities ( referenced in @OneToMany, @ManyToMany and ManyToOne) must be annotated with @Entity and @Audited (if any of the has the @Audited, then all classes should have this annotation also) Common error