• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to use 2 database in hibrnates.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
sure nandu
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just use two configurations. E.g. :
 
reply
    Bookmark Topic Watch Topic
  • New Topic