-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed many to many mapping by using an Association Table, related to …
…this SO question #https://stackoverflow.com/questions/77943523 . Not related to the SO question I also have bat colors and car colors show up as a CSV on the table, but so far have failed to populate the combo box with those values.
- Loading branch information
1 parent
4be15ce
commit f31fea4
Showing
8 changed files
with
467 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/main/java/com/example/application/data/SamplePersonAssocCar.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.example.application.data; | ||
|
||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
import com.fasterxml.jackson.annotation.JsonManagedReference; | ||
import jakarta.persistence.*; | ||
import jakarta.validation.constraints.Email; | ||
import org.hibernate.annotations.LazyCollection; | ||
import org.hibernate.annotations.LazyCollectionOption; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.util.Set; | ||
|
||
@Entity | ||
public class SamplePersonAssocCar extends AbstractEntity { | ||
|
||
@JsonBackReference | ||
@ManyToOne | ||
@JoinColumn(name = "samplePerson") | ||
private SamplePerson samplePerson; | ||
|
||
@JsonBackReference | ||
@ManyToOne | ||
@JoinColumn(name = "car") | ||
private Car car; | ||
|
||
public SamplePerson getSamplePerson() { | ||
return samplePerson; | ||
} | ||
public void setSamplePerson(SamplePerson value) { | ||
this.samplePerson = value; | ||
} | ||
|
||
public Car getCar() { | ||
return car; | ||
} | ||
public void setCar(Car value) { | ||
this.car = value; | ||
} | ||
|
||
|
||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/example/application/data/SamplePersonAssocCarRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.example.application.data; | ||
|
||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
|
||
public interface SamplePersonAssocCarRepository | ||
extends | ||
JpaRepository<SamplePersonAssocCar, Long>, | ||
JpaSpecificationExecutor<SamplePersonAssocCar> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
insert into ape(version, id, color) values (1, 1, 'apricot') | ||
insert into ape(version, id, color) values (1, 2, 'apple') | ||
insert into car(version, id, color) values (1, 1, 'cocoa') | ||
insert into car(version, id, color) values (1, 2, 'cream') | ||
insert into sample_person(version, id, ape, cars, d, e) values (1, 1, 1, ARRAY [1, 2], 'd', 'e') | ||
insert into bat(version, id, color, zooKeeper) values (1, 1, 'brown', 1) | ||
insert into bat(version, id, color, zooKeeper) values (1, 2, 'blue', 1) | ||
insert into sample_person(version, id, ape, d, e) values (1, 1, 1, 'd', 'e') | ||
insert into sample_person(version, id, ape, d, e) values (1, 2, 2, 'd', 'e') | ||
insert into sample_person_assoc_car(version, id, sample_person, car) values (1,1,1,1) | ||
insert into sample_person_assoc_car(version, id, sample_person, car) values (1,2,1,2) | ||
insert into sample_person_assoc_car(version, id, sample_person, car) values (1,3,2,2) | ||
insert into bat(version, id, color, zookeeper) values (1, 1, 'brown', 1) | ||
insert into bat(version, id, color, zookeeper) values (1, 2, 'blue', 1) | ||
insert into bat(version, id, color, zookeeper) values (1, 2, 'burgundy', 2) | ||
|
Binary file not shown.
Oops, something went wrong.