How to enable multi-tenancy in Hibernate 4 with JPA?

前端 未结 2 1817
轮回少年
轮回少年 2021-02-08 10:53

It looks to me as though support for multi tenancy has been added to hibernate for nearly six months now and updated at least once since.

It looks fairly trivial to obta

2条回答
  •  温柔的废话
    2021-02-08 11:41

    You can configure it via properties in persistence.xml as follows:

    
    
    
    

    If you use SCHEMA as multi-tenancy strategy hibernate.multi_tenant_connection_provider is not needed.

    You can also set these properties in your code and pass them in a map to Persistence.createEntityManagerFactory(). In this case you can pass an object instance, not just a class name.

    More info in Hibernate documentation.

提交回复
热议问题