-->
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.  [ 4 posts ] 
Author Message
 Post subject: Indirect datasource property configuration
PostPosted: Tue Jun 21, 2005 7:06 am 
Newbie

Joined: Tue Jun 21, 2005 6:31 am
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:3

Name and version of the database you are using: Oracle 9i

Hello all.

Im trying out Hibernate in our application, wired through Spring. I've managed to define the PropertyConfigurator bean in the Spring configuration, and that is reading hibernate.properties, for reading db connection data, and in the 'datasource' bean definition of Spring, I am using variables as ${hibernate.connection.url}, ${hibernate.connection.username} etc.

Hibernate documentation states that Hibernate looks for hibernate.properties, or hibernate.cfg.xml in the classpath and if it doesnt find those it doesnt have its configuration. So how can i plug some configuration without hibernate actually knowing hibernate.properties or hibernate.cfg.xml.?

I dont want to define Hibernate specific variables in my Spring configuration. I would like to have a way, whereby allowing me to put my own variables in my Spring configuration, and plug the Hibernate variables into those variables somehow, so that Spring reads not Hibernate specific, but my variables and my variables in turn are reading / plugged by Hibernate specific variables. Makes any sense so far ? :). Example:

<!-- database configuration from property file -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName"> <value>${hibernate.connection.driver_class}</value>
</property>

<property name="url"> <value>${hibernate.connection.url}</value></property>
<property name="username"><value>${hibernate.connection.username}</value></property>
<property name="password"><value>${hibernate.connection.password}</value></property>
</bean>


This way, I can define my Spring configuration once, with my datasouce variables (database url, driver, username, pwd etc) and i can choose to use Hibernate and plug somehow Hibernate variables into mine (hibernate.connection.url, hibernate.connection.username) or later on try out some other persistence framework (toplink?) and plug its variables into my original Spring defined variables, and thus I wont have to change my Spring config files!.

Anybody got any million dollar ideas.?? please .
thanks so much.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 7:24 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
This is not a Spring forum.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 8:01 am 
Newbie

Joined: Tue Jun 21, 2005 6:31 am
Posts: 4
Ok. how about this.

Is there a way to plug in datasource configuration into Hibernate (hibernate.connection.xxx), when its not present in hibernate.properties or hibernate.cfg.xml.

Maybe somehow manipulating SessionFactory etc etc??

Thanks so much.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 21, 2005 8:16 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Of course, as explained in the reference documentation.


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