Relationship between three tables - Postgresql

Asked

Viewed 207 times

2

need to make a relationship between three tables in the database in Java, created the two entities and the methods of the two entities, now need to insert a relationship table that has only two fields and each of them referencing the respective entities, someone has an idea how to do this?

Project Photo

inserir a descrição da imagem aqui

Photo from the database

inserir a descrição da imagem aqui

  • In terms of Postgresql you resolve with CREATE TABLE and the FOREIGN KEY clause. https://www.postgresql.org/docs/current/sql-createtable.html

  • I want to do in java

  • Do in java, you say Hibernate?

  • Yes, do in Ibernate!

  • 1

    @A.Carlos , do you understand that when you work with Hibernate, you don’t need to create the tables inside the database? this image is from your database?

  • Yes, that photo is from my database

  • @A.Carlos can insert its model classes?

  • I can, I just don’t know how

  • @A.Carlos Puts as source code the two classes

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.