I have the following problem: I created a database named Test and it has two schemas: schema1 and schema2. Within each schema has a table: schema1 - > table1 schema2 - > table2
It turns out that if I try to make a relationship with SpringBoot using annotations between table1 and table2, they do not see each other. with pure sql, with you, just inform the table with schema. schema1.tabela1 schema2.tabela2.
But how do I do this Spring Boot? Here I am.
@Entity @Table(schema = "schema_1")
public class Tabela1 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
@OneToMany(mappedBy = "tabela1")
private List<Tabela2> tabela2= new ArrayList<>();
publicTabela1() {
}
}
second table
@Entity
@Table(schema = "schema_2")
public class Tabela2 implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String number;
@ManyToOne
@JoinColumn(name = "fk_tabela1")
private Tabela1 tabela1;
public Tabela2() {
}
}