Announcement Announcement Module
No announcement yet.
Indirect datasource property configuration Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Indirect datasource property configuration

    Need help with Hibernate? Read this first:

    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, 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, 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 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.DriverM anagerDataSource">

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

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

    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.