Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

DAO with Hibernate(multiple datasources)

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

I am using DAO with hibernate in my persistance layer.

but my requirment is such that inside the DAO implimentation class i want to make use of two datasources.

thi is my DAO

public class TestDaoImpl implements TestDao

{
public TestReturnVO insertInfo(TestVO testVO)
{

System.out.println("INSERT INFO INTO TABLE1 OF 'DATABASE1' using Hiberante datasource ");
return TRVO;
}


public TestReturnVO retrieveInfo(TestVO testVO)
{

System.out.println("Retrieve INFO FROM TABLE1 OF 'DATABASE2' Using Hiberante datasource");
return TRVO;
}


}

Any idea how i should go about implimenting the above scenario? Do i use abstract factory design pattern in my DAO to connect to Multiple databases?

How should i change the hibernate configuration file so that it can use two datasources instead of one?

any implimentation code would be greatly appreciated

thanks
Jay
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hibernate works from a SessionFactory, and a SessionFactory is associated with one DataSource. If you need to use two, you need two SessionFactories. The logic of which to open a session in for a particular object will need to be done manually in your DAO.
[ June 05, 2007: Message edited by: Paul Sturrock ]
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic