Skip to content

The goal of this project is to study the JPA relationships: one-to-one, one-to-many / many-to-one, and many-to-many.

Notifications You must be signed in to change notification settings

ivangfr/spring-data-jpa-relationships

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

spring-data-jpa-relationships

The goal of this project is to study the JPA relationships: one-to-one, one-to-many / many-to-one, and many-to-many.

Proof-of-Concepts & Articles

On ivangfr.github.io, I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.

Additional Readings

Prerequisites

Start Environment

In a terminal and inside the spring-data-jpa-relationships root folder, run the following command:

docker compose up -d

Running application using Maven

In a terminal and inside the spring-data-jpa-relationships root folder, run the command below:

./mvnw clean spring-boot:run

Once the application is running, you can access its Swagger website at http://localhost:8080/swagger-ui.html.

Useful Commands

  • Postgres
    docker exec -it postgres psql -U postgres -d jparelationshipsdb
    \d persons
    select * from persons;
    

    Type exit to exit

Shutdown

  • To stop the application, go to the terminal where it is running and press Ctrl+C;
  • To stop and remove docker compose containers, network and volumes, go to a terminal and, inside the spring-data-jpa-relationships root folder, run the following command:
    docker compose down -v
    

Running Tests

In a terminal and inside the spring-data-jpa-relationships root folder, run the following command:

./mvnw clean test

JPA relationships

One-to-One with Simple Primary Key

teams_team_details

[Medium]: Understanding Relationships in JPA: One-to-One with Simple Primary Key

One-to-One with Shared Primary Key

persons_person_details

[Medium] Understanding Relationships in JPA: One-to-One with Shared Primary Key

One-to-Many with Simple Primary Key

restaurants_dishes

[Medium] Understanding Relationships in JPA: One-to-Many with Simple Primary Key

One-to-Many with Composite Primary Key

players_weapons

[Medium] Understanding Relationships in JPA: One-to-Many with Composite Primary Key

Many-to-Many with Simple Primary Key

writers_books

[Medium] Understanding Relationships in JPA: Many-to-Many with Simple Primary Key

Many-to-Many with Simple Primary Key and Extra Column

reviewers_articles

[Medium] Understanding Relationships in JPA: Many-to-Many with Simple Primary Key and Extra Column

Many-to-Many with Composite Primary Key and Extra Column

students_courses

[Medium] Understanding Relationships in JPA: Many-to-Many with Composite Primary Key and Extra Column

References

One-to-One

One-to-Many / Many-to-One

Many-to-Many

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages