Hello,
I have a requirement that the data model must be split between multiple physically separate databases.
I have created multiple SessionFactorys to provide a separate session for each database, and this works well for the DAOs and any manual data loading.
I cannot figure out how to get this to work for the direct loading of data through entity relationships.
e.g.
Code:
@Entity
@Table(name = "DatabaseATable")
//Class is stored in database A
public class DatabaseAClass
{
private DatabaseBClass bClass;
...
}
@Entity
@Table(name = "DatabaseBTable")
//Class is stored in database B
public class DatabaseBClass
{
...
}
What I want to be able to do is:
Code:
HibernateUtil.getDatabaseASession().get(DatabaseAClass.class, id).getBClass();
Where B class is loaded from Database B based on the primary key in DatabaseAClass.
Is there anyway I can do this?
Thanks,
Josh