1. Setting Up Hibernate ORM
Snippets and Commands
build.gradle
plugins {
id 'org.springframework.boot' version '2.4.4'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'org.postgresql:postgresql'
}
src/main/resources/application.properties
# Which type of database
spring.jpa.database=POSTGRESQL
# The database url containing the domain it is hosted on, port number, and database name
spring.datasource.url=jdbc:postgresql://localhost:5431/demo
spring.datasource.username=demo_user
spring.datasource.password=demo_pass
# Show executed sql code in the logs
spring.jpa.show-sql=true
# Generate database schema automatically on start
spring.jpa.generate-ddl=true
# Will drop any current schema and create a new one
spring.jpa.hibernate.ddl-auto=create
2. Mapping Class to Database with Hibernate ORM
Top comments (0)