【问题标题】:Hibernate multi-tenant naming strategyHibernate 多租户命名策略
【发布时间】:2019-04-16 03:33:14
【问题描述】:

我正在构建一个应用程序,其中多个租户在数据库实例(相同的 mysql 数据库)上有自己的一组表。我希望将表命名为:tenantA_users, tenantA_orderstenantB_users, tenantB_orders

我尝试实现类似this 的东西,但似乎Configuration conf = new Configuration().configure();legacy way to bootstrap

有没有办法将Interface PhysicalNamingStrategy 实现为非静态的,所以我可以将tenantName 字符串附加到类中提供的带注释的@Table 名称中?

例如:

@Entity
@Table(name = "custom_order")
public class CustOrder {

我希望命名为tenantA_custom_ordertenantB_custom_order,而不是tenantA_CustOrder

【问题讨论】:

    标签: java mysql hibernate hibernate-mapping multi-tenant


    【解决方案1】:

    我使用MetadataBuilder applyPhysicalNamingStrategy(PhysicalNamingStrategy namingStrategy)完成了它

    这样我可以将tenantName 字符串发送到namingStragegy 构造函数。

    【讨论】:

      猜你喜欢
      • 2023-03-21
      • 1970-01-01
      • 2017-01-02
      • 2016-01-11
      • 2015-11-16
      • 1970-01-01
      • 1970-01-01
      • 2020-06-06
      相关资源
      最近更新 更多