-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate with different data sources..
PostPosted: Sun Jun 25, 2006 3:36 pm 
Newbie

Joined: Thu Jun 22, 2006 9:39 am
Posts: 1
Hi
In Hibernate 3.0, i have to use different data sources for oracle database(different IPaddress,Username,password) in an application. I mean, we use oracle database in different servers for different queries. Some times i have to connect to the server xyz for query1 and connect to the server ABC for query2 with different username,password and server DEF for query3. I know hibernate has dailect parameter for different databases. In my case dailect is useless. Its alwasys oracle only. But my connection pramaters change . Please advice me about below questions.. Note: we dont use spring framework

1) DO i need to go for DAO framework to have a seperate class implementing the same interface for those different data sources. Is hibernate comes with any DAO framework to support this. We dont use spring framework in our project. Do we need to code DAO framework even if we use hibernate.

2) With out DAO framework to support different data sources, can we come up with different hibernate.cfg.xml files with different connection parameters. If we are going to do like this , where are we seperating the Data access layer from persistence.

3) Ibatis has DAO framwork. If hibernate doesn't support different data sources( Iam not talking about data bases..we have only oracle database)..why should we use hibernate instead of other OR mapping tools.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jun 25, 2006 4:40 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
In Hibernate, using different datasources just means creating a sessionfactory for each. Then executing SQL on a particular database just means you must work with the right Session objet (SessionFactory.openSession() method)

Have a look at this post : http://forum.hibernate.org/viewtopic.ph ... ionFactory

The poster wrote a HibernateUtil class based on the one in the ref doc. This one handles three different SessionFactories. Then when you want to access the A Database, you just get a A Session with HibernateUtil.openASession() and so on.

This behaviour has nothing to do with the DAO framework, or maybe your mean that you want to be able to call openSession() where everywhere and you'd get a A session from some Daos, a B Session for others, and so on automatically ?

If so, I think it's possible but not included in standard. But I don't see the real difficulty to do it yourself. Or just specify your need here, maybe someone will help you doing it :-).

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.