-->
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.  [ 7 posts ] 
Author Message
 Post subject: Mapping classes to multiple database schemas
PostPosted: Mon Sep 12, 2011 9:53 pm 
Newbie

Joined: Tue Jun 08, 2004 7:44 pm
Posts: 12
I have been unsuccessful finding answers/topics in this forum related to the following scenario.

Ours is a distributed high volume data driven SOA system written originally in C and now getting migrating to Java. The database schema is distributed and follows the pattern of one database per top level entity. For e.g: Customer is in CustomerDB, Account is in AccountDB, user in UserDB and so on. There may be related tables to each of these entities in the same database, for e.g: UserDB has UserProfile, etc but as the entire system, the high level domain objects are residing in their own distributed database schemas. Due to database limitations when a table in one schema grows too big, it gets split up and put into its own database, giving it the more resources. A lot of these data model decisions are due to the legacy I won't be able to answer why it has been designed this way. The C services seem to work well in this model and most of the business logic are database centric.

Now that we are moving to Java, we want to take advantage of the OO features and write code rich in OO and not Db centric. The problem now is how do I map my Java entities to DB objects that are residing in multiple databases? I want to be able to navigate through the object graph from Customer to Account to Order etc. I looked at the Hibernate Shards but it only deals with multi-tenancy and partitioning based on the data range, all the databases are still having the same schema.

Any usecase logic would involve call to multiple databases to gather its data and work on it (today it happens as discrete service calls to each of these databases). How do I accomplish mapping Java classes in my application to multiple databse schemas, thereby using all the Hibernate features? Any advise on this problem would be very helpful

Thanks
Sairam


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Tue Sep 13, 2011 4:53 pm 
Newbie

Joined: Tue Jun 08, 2004 7:44 pm
Posts: 12
It looks like EclipseLink has a feature called "Composite Persistence Units" to handle this scenario. Is there a Hibernate equivalent for this? Thanks

Sairam


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Thu Sep 15, 2011 4:59 pm 
Newbie

Joined: Tue Jun 08, 2004 7:44 pm
Posts: 12
Hibernate experts - can anyone respond??


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Mon Sep 26, 2011 7:43 am 
Newbie

Joined: Mon Sep 26, 2011 7:40 am
Posts: 4
Hi,

I want to build a multy tenant (seperate schema) application with Hinernate 4.

I cannot find any code examples,

Can you maybe post some examples of yours?

Thanks
Tomer


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Mon Sep 26, 2011 4:11 pm 
Regular
Regular

Joined: Sat Apr 23, 2005 7:28 am
Posts: 52
Sairam
I'm not sure this applies to your particular use case - but I have successfully written applications that connect to multiple disparate database using Hibernate. The solution was to write multiple hibernate.cfg.xml files : hibernate1.cfg.xml, hibernate2.cfg.xml, hibernate3.cfg.xml etc. Together with multiple HibernateUtil classes HibernateUtil1, HibernateUtil2, HibernateUtil3 etc each of which references a specific hibernate.cfg.xml file.

Using this pattern, you can map Customer, Account and User to different database.

From what you indicate though, I suspect that the data mapping is only the start of your problems.

David


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Mon Sep 26, 2011 5:06 pm 
Newbie

Joined: Tue Jun 08, 2004 7:44 pm
Posts: 12
David,
Correct. Mapping is not an issue but using those mappings to interpret relationships and creating an object graph, persist it across databases is a problem

Regards,
Sairam


Top
 Profile  
 
 Post subject: Re: Mapping classes to multiple database schemas
PostPosted: Sun Oct 02, 2011 2:44 am 
Newbie

Joined: Mon Sep 26, 2011 7:40 am
Posts: 4
Hi David,

Can you maybe post an example of how you work with seperate HBM files for multiple schemas?

Thank you in advanced,
Tomer


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.