我正在构建一个应用程序,其中多个租户在数据库实例(相同的mysql数据库)上有自己的一组表。我希望表格的名称如下:tenantA_users, tenantA_orders
,tenantB_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_order
tenantB_custom_order
,而不是tenantA_CustOrder
。
我用MetadataBuilder applyPhysicalNamingStrategy(PhysicalNamingStrategy namingStrategy)完成了它
这样我就可以将tenantName字符串发送到namingStragegy构造函数。