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: object graph spread accross database
PostPosted: Wed Nov 26, 2008 9:49 am 
Newbie

Joined: Wed Nov 26, 2008 7:55 am
Posts: 2
I have 2 tables namely Person and Dept with many to many relationship between them. Then its obvious that I have refer each table from others mapping file. e.g. I have to refer Person table from Dept.hbm.xml and vice a versa.

Now my these two table lie on different database. For this purpose I have v created 2 hibernate.cfg.xml. One having person.hbm.xml and second having dept.hbm.xml. When I try to create a session factory by configuring , the cfg file with person.hbm.xml inside it.
It gives me org.hibernate.MappingException: An association from the table Person refers to an unmapped class: com.db.objectmodel.Dept

Does hibernate supports such scenario where object graph is spread across databases? I have looked into hibernate shards but does not support as it meant for solving horizontal partitioning.

Thanks in advance,

_________________
-- yogesh g k


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 26, 2008 6:27 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
When mapping a <class> you can try setting the 'catalog' and/or 'schema' attributes. All mapping files must go into the same Configuration and SessionFactory.

Something like

Code:
Person.hbm.xml:
<class name="Person" table="Person" catalog="DbPerson" ... >

Dept.hbm.xml
<class name="Dept" table="Dept" catalog="DbDept" ...>


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.