postgresql - Postgres中不同模式之间的SpringBoot 2 JPA关系
问题描述
需要帮助解决这个问题:我在同一个数据库中有两个不同模式的表:
DB_test schema_1 shema_2
在每个模式中,我都有不同的表:
schema_1 -> 客户端 schema_2 -> 电话。
我的代码
表格1
@Entity @Table(schema = "schema_1")
public class Client implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
@OneToMany(mappedBy = "client")
private List<Phone> phones = new ArrayList<>();
public PessoaFisica() {
}
}
表 2
@Entity
@Table(schema = "schema_2")
public class Phone implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String number;
@ManyToOne
@JoinColumn(name = "fk_client")
private Client client;
public Client() {
}
}
所以这种关系是行不通的。但是如果这两个表在同一个模式中,它就可以工作。一个模式表应该怎么做才能看到另一个模式的表。
解决方案
推荐阅读
- java - 如何在 Grafana 中创建健康检查?
- javascript - 插入 testcafe 中的 on_page_change 事件
- c++ - CMake 和 Visual Studio 项目设置
- coldfusion - 针对不同应用的不同位置的 Coldfusion 映射
- excel - 为什么在 VBA 中引发用户定义的错误时需要使用 vbObjectError 常量?
- excel - 通过 VBA 引用的工作簿不接受变量
- ksqldb - 从两个 ksql 流中获取一个 ksql 流
- jquery - Jquery:只选择树中第一次出现的类
- ruby-on-rails - HTTP 503 由于:请求队列已满(配置的最大大小:100)apache + passanger
- c# - 我如何发送正文而不仅仅是状态 - .NET Core API