-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Entity Attachment with Multiple Databases
PostPosted: Thu Jan 19, 2012 11:33 pm 
Newbie

Joined: Thu Jan 19, 2012 11:19 pm
Posts: 2
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


Top
 Profile  
 
 Post subject: Re: Entity Attachment with Multiple Databases
PostPosted: Tue Jan 24, 2012 12:48 am 
Newbie

Joined: Thu Jan 19, 2012 11:19 pm
Posts: 2
A substantial update to the question, as well as a working [potential] solution:
http://stackoverflow.com/questions/8980 ... -databases


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.