Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Hibernate mapping across multiple databases

  Asked By: Diane    Date: Apr 27    Category: Java    Views: 1503

I am quite in an ugly situation where I have to move one of the
hibernate entities to another database which may or may not be on the
same physical database that the other entities are. Well, not a big
deal, I need to define a new set of settings and it rolls in the rest.
However, life sometimes is the !@#@@!!@@, right? The problem is that
entities are joined and hibernate doesn't like. Having dug up
hibernate and spring forums, I am certain my only late comer chance is
to write my own CRUD, and you know it is not going to be fun and at
the same time I don't like hacked open source codes. The other
alternative I have is to go in the code and fix up everything. Well,
besides the man power it takes, it has a definite performance drawback
in our system (I cut the Romeo Juliet part that explains why for the
love of the national napkin saving group, NNSG). Anyways, what I do
now? Any ideas?



2 Answers Found

Answer #1    Answered By: Kanya Jainukul     Answered On: Apr 27

We once had this problem (I don't know if this is similar to your's):
We wanted to connect to multi databases, which had same database  schema. This is possible to switch the actual database connection, the hibernate  will not care about it.

Have a look at:

Answer #2    Answered By: Connie Wallace     Answered On: Apr 27

Thanks for the links. Unfortunately the two databases  do not share a consistent schema. The point in my assignment is to separate mutable data from immutable data for performance reasons. I had a suggestion from a friend to implement an interceptor to does the hacking seamlessly. The interceptor thing will sure do the job in my case. However, I am database  bound now, and I have the mandate to stay away from unnecessary database talks. Well, I have fixed the problem so far by fixing up the mappings in the original database to use the immutable object, which is generously cached, and single select statements on the mutable data with a short term cache for they are not very volatile.

Didn't find what you were looking for? Find more on Hibernate mapping across multiple databases Or get search suggestion and latest updates.