-->
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: Multiple Databases in a single query
PostPosted: Wed Feb 04, 2004 8:11 am 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
Ok.. so I'm happy that hibernate will be fine in my multi-database environment.. I can just provide my own connection.

However

What if... (and please don't talk to me about this design.. it's not my doing)

What if we have (lets make it simple) two databases and a table in database 2 has a foreign key to a table in database 1.. so a SQL statement might be

SELECT * FROM db2.customer, db1.address WHERE customer.addressId = address.id;

Or something similar..

Could I just refer to the tables in the "central" DB1 as db1.address (for example) when defining my mapping? If so, it doesn't matter what connection I pass to the sessionfactory right?

This is my last niggle before using hibernate..


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 1:03 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
What do you mean by "database"? Is this MySQL?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 1:21 pm 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
Yes - sorry should have mentioned that!! MySQL 4


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 1:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Yeah, it works, I think. Just specify the database name using the schema attribute in your mappings. Its not really a schema, so note that SchemaExport gets confused if you try to use the notion of a "schema" to represent the MySQL notion of a "database", but the Hibernate core works fine.

We need to add a notion of "catalog" (I *think* that is the ANSI standard work for what MySQL calls "database), for the benefit of SchemaExport.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 2:41 pm 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
From what I've read, SchemaExport attempts to create something like a DDL file to create the various tables? Although this would work with our core tables, it wouldn't be possible to genereate the account "catalogues" anyway becuase they are dynamic.. I guess you could recreate existing catalogues if you could inform SchemaExport of their existence but there are over 1000 of them...(and one more generated each time a new account is opened)

It's a tricky design and one that I have mixed feelings about. I can see why it was done - for future scalability and speed.. but it sure makes my life hell!

-M-


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 2:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
eh??

You don't have to use SchemaExport if you already have existing tables, obviously.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 04, 2004 4:10 pm 
Newbie

Joined: Mon Feb 02, 2004 8:27 pm
Posts: 17
:) That's not quite what I meant but it's not important.. suffice to say, the SchemaExport isn't of great use to me.


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.