在 Spring Data JPA using Schema Multi Tenant 中,如何与其他模式加入相同的实体

In Spring Data JPA using Schema Multi Tenant, how to join with other schema although the same entity

我在 Spring Data JPA 中使用基于模式的多租户。

properties.put("hibernate.multiTenancy", MultiTenancyStrategy.SCHEMA);

“Common”模式和“A”模式的table结构相同。
这两个模式是使用相同实体的多租户结构。
“A”架构和“通用”架构中有一个名为 User 的条目。
我如何加入这两个实体?

我想创建这样的查询。 (架构当前被租户设置选为 A。)

select u.* from user u left join common.user u2 on u.common_id = u2.id;

@Entity
public class Entity {
    @Id
    private Long id;
    private Long commonId; // right?
}

我应该在不使用 JPQL 的情况下使用本机查询吗?

JPA 做不到这一点。

顺便说一句。 JPA 不知道作为 Hibernate 功能的多租户。