Hibernate中的多租户

Hibernate中的多租户

本文介绍了Hibernate中的多租户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用单独的模式方法将多租户添加到Java应用程序中,如。


I am trying to add multi tenancy to a java application using the separate schema approach as outlined in this webinar

I wanted to know how would i configure mulitple datasources via spring perhaps by using properties files and get the datasources from the spring context based on tenant id.

More importantly though i want to be able to configure my custom connection provider implementation that supports this multi-tenancy feature to be used by hibernate instead of the injectedconnectionprovider that it uses by default.

How can i achieve this.

解决方案

Use the AbstractRoutingDataSource. See my answer located @ Multiple Entity Manager issue in Spring when using more than one datasource.

这篇关于Hibernate中的多租户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:42