Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:58:50+00:00 2026-05-11T03:58:50+00:00

How do I get Spring to load Hibernate’s properties from hibernate.cfg.xml ? We’re using

  • 0

How do I get Spring to load Hibernate’s properties from hibernate.cfg.xml?

We’re using Spring and JPA (with Hibernate as the implementation). Spring’s applicationContext.xml specifies the JPA dialect and Hibernate properties:

<bean id='entityManagerFactory' class='org.springframework.orm.jpa.LocalEntityManagerFactoryBean'>     <property name='jpaDialect'>         <bean class='org.springframework.orm.jpa.vendor.HibernateJpaDialect' />     </property>     <property name='jpaProperties'>         <props>             <prop key='hibernate.dialect'>org.hibernate.dialect.MySQLInnoDBDialect</prop>         </props>     </property> </bean> 

In this configuration, Spring is reading all the Hibernate properties via applicationContext.xml . When I create a hibernate.cfg.xml (located at the root of my classpath, the same level as META-INF), Hibernate doesn’t read it at all (it’s completely ignored).

What I’m trying to do is configure Hibernate second level cache by inserting the cache properties in hibernate.cfg.xml:

<cache      usage='transactional|read-write|nonstrict-read-write|read-only'     region='RegionName'     include='all|non-lazy' /> 
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:58:50+00:00Added an answer on May 11, 2026 at 3:58 am

    Try something like this…

    <bean     id='mySessionFactory'     class='org.springframework.orm.hibernate3.LocalSessionFactoryBean'>      <property name='configLocation'>             <value>             classpath:location_of_config_file/hibernate.cfg.xml         </value>     </property>      <property name='hibernateProperties'>         <props>              ...               </props>         </property>  </bean> 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Spring with Hibernate as a JPA provider and are trying to get
I am using Hibernate 3.6, JPA 2.0, and Spring 3.0.6. I have fields in
I am using Jboss5 and I'm trying to utilize Hibernate and Spring to load
I need to get the spring application context from a non bean object. In
I'm using Spring Security 3.0.7 How can I get with java code the access
I need to get a Properties object into my spring bean so I can
We use iBatis + Spring intensively. Everything we get from the DB is fetched
I am using Spring+Hibernate for an operation which requires creating and updating literally hundreds
I am using Spring MVC 2.5, and I am trying to get a JSTL
I am using Spring Web MVC as frontend on hibernate with transactions (all annotation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.