0
I have the following problem: I created a database called Test and inside there are two schemas: schema1 and schema2. Within each schema has a table: schema1 -> Tabela1 schema2 -> table2
It turns out that if I try to make a relationship with Springboot using Annotations between Table 1 and table2, they don’t see themselves. with pure sql, with you, just inform the table with schema. schema1.Tabela1 schema2.table 2.
But how do I do Spring Boot? Here’s my code.
@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() {
}
}
It worked perfectly. Thank you very much
– Rodrigo Batista
@Rodrigobatista, if the answer helped, mark your colleague’s answer as the correct one :)
– Dherik