2

I am trying to migrate my application from jboss As 5 to jboss As 7.1.1.final. I have 4 databases from mssql and 1 db from postgres. I have before a har service that provide one sessionfactory and i want to do the same thing forjboss as 7 (not support har probably).

So my question is :

How can i configure one hibernate sessionFactory for multi persitenceunit ? or how can i use one persistenceunit for multi datasources ?

And how to get the sessionfactory from one method ?

please help.

sorry for my english

thx.

1 Answers1

0

Hibernate 4 supports multitenancy. you can configure multitenancy in your application by using that you can configure any number of DB.

<prop key="hibernate.multiTenancy">DATABASE</prop>
<prop key="hibernate.connection.datasource">
    ${hibernate.dataSource.jndiName}
</prop>
<prop key="hibernate.tenant_identifier_resolver">multitenancy.CurrentTenantResolver</prop>
<prop key="hibernate.multi_tenant.datasource.identifier_for_any">Default</prop>

Above is setting for hibernate in Spring. you can check details in hibernate documentation.

Neeraj
  • 327
  • 1
  • 8