Announcement Announcement Module
Collapse
No announcement yet.
hbm2java, hibernate.cfg.xml, and applicationContext.xml Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • hbm2java, hibernate.cfg.xml, and applicationContext.xml

    I've used Hibernate in several projects, but am very new to Spring. If my initial perusal through the docs is correct I see that, with Spring, I no longer specify database connection info in hibernate.cfg.xml. Instead, I specify it in applicationContext.xml where the hibernate session factory is configured. That's great. However, I don't easily see how I can get rid of hibernate.cfg.xml because I use that with hbm2java to build my hibernate beans.

    What does everyone else do? Do you just maintain connectiong information in two config files: hibernate.cfg.xml, and applicationContext.xml?

    Thanks in advance.

  • #2
    Re: hbm2java, hibernate.cfg.xml, and applicationContext.xml

    Originally posted by richg
    I've used Hibernate in several projects, but am very new to Spring. If my initial perusal through the docs is correct I see that, with Spring, I no longer specify database connection info in hibernate.cfg.xml. Instead, I specify it in applicationContext.xml where the hibernate session factory is configured. That's great. However, I don't easily see how I can get rid of hibernate.cfg.xml because I use that with hbm2java to build my hibernate beans.
    I want the same thing and do it as follows::

    Code:
    	<bean id="sessionFactory"
    		  class="org.springframework.orm.hibernate.LocalSessionFactoryBean">
    
    		<property name="configLocation"
    				  value="WEB-INF\classes\hibernate.cfg.xml"/>
    
    		<property name="dataSource"
    				  ref="dataSource"/>
    	</bean>

    Comment


    • #3
      That's just what I was looking for. I'll give it a try today. Thanks so much for your note.

      Comment

      Working...
      X