This content originally appeared on DEV Community and was authored by Software Development Academy
Adding a Car Class
One-To-Many Relation
Clarification
At the end of the video, the person
column in the car table (the table to the right) is called a foreign key column as the values in the column are ids on the person table (table to the left)
One-To-Many Implementation
Avoiding Recursive JSON Representation
Snippets & Commands
JSON annotations
Ignore the property completely:
@JsonIgnore
or make the property only be rendered as the id:
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
@JsonIdentityReference(alwaysAsId = true)
Updating Car & Validation
Snippets & 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'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtimeOnly 'org.postgresql:postgresql'
}
This content originally appeared on DEV Community and was authored by Software Development Academy
Software Development Academy | Sciencx (2021-04-08T13:17:00+00:00) Entity Relationships Part 1: One-To-Many. Retrieved from https://www.scien.cx/2021/04/08/entity-relationships-part-1-one-to-many/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.