tags:

views:

30

answers:

1

Hello, I've to use more than one database together (on the same connection... ) via mysql. I want to use hibernate, but all I can find around is to use two sessionfactories. Now the problem is: how can I do mappings like one-to-many among different sessionfactories... seems not possible as I have to put mapping in one configuration and I can't spread it ... Any suggestion?

+1  A: 

You might use Hibernate Shards

https://www.hibernate.org/429.html

Here is some quick info

Hibernate Shards is a subproject developed and donated by Google. It allows the management of several SessionFactory instances across different databases (or users), optionally created from a "prototype" configuration.

Pros: A pre-made solution.

Cons: Not appropriate for large numbers of schemas since there is effectively one SessionFactory per database user/schema.

Bahadir Cambel