MyEclipse Enterprise Workbench
[Logo] JavaRanch » JavaRanch Saloon
  Search | FAQ | Recent Topics | Hot Topics
Register / Login


Win a copy of JBoss AS 5 Development this week in the JBoss forum
or Spring Dynamic Modules in Action in the Spring forum!
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Object Relational Mapping
 
RSS feed
 
New topic
Author

how to use 2 database in hibrnates.

sure nandu
Greenhorn

Joined: Oct 16, 2006
Messages: 18

hai everybody,

i just wanted to know how can we use 2 databases using hibernates.
--> to create some tables in mysql server and some other databases
in say oracle server. we can define 2 sessionfactory in
<hibernate-configuration>. but how to specify specific table to be created
in particular database.
if anyone knows please reply.any response will be appreciated. thank you.

regards
nandu
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Messages: 8409

You want to create one logical model that spans two physical databases of different types? That is a very unusual setup. Typically, if you did want to do this the databases would be the same type and you would let the database itself manage the data model, and Hibernate would just use it as if it were one database. Why do you need to do this?
[ November 10, 2006: Message edited by: Paul Sturrock ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
sure nandu
Greenhorn

Joined: Oct 16, 2006
Messages: 18

thanks for the reply.
In one of the seminars i attended on hibernates i got this question.
so i just wanted to know whether it is possible to use 2 databases from hibernates in a single application.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Messages: 8409

Ah perhaps I misunderstood your original question. Using two or more database from one application via Hibernate is easy. Just create a SessionFactory for each schema and swap as appropriate, Hibernate will manage the differences between the databases transparently.

Having one model split across two databases is not easy though.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Halcon Guatemala
Ranch Hand

Joined: Sep 06, 2006
Messages: 57

Hi to @ll, I'm not sure about how could I setup hibernate (either hibernate.cfg.xml or hibernate.properties) to use 2 databases?

Thanks in advance

"La verdadera sabidur�a viene del temor de Dios"
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Messages: 8409

Just use two configurations. E.g. :

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
 
 
Reply Bookmark it! Watch this topic JavaRanch » Forums » Java » Object Relational Mapping
 
RSS feed
 
New topic
MyEclipse Enterprise Workbench