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 4074522
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:10:54+00:00 2026-05-20T17:10:54+00:00

How do you configure the Hibernate class mappings of class org.springframework.orm.hibernate3.LocalSessionFactoryBean in the Spring

  • 0

How do you configure the Hibernate class mappings of class org.springframework.orm.hibernate3.LocalSessionFactoryBean in the Spring application context? I want to move the session factory class mappings from the following hibernate.cfg.xml to the corresponding Spring session factory bean so that I may eliminate hibernate.cfg.xml.

File hibernate.cfg.xml:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <!-- ... -->
        <mapping resource="Queries.hbm.xml" />
        <mapping class="com.company.app.common.model.Account" />
        <mapping class="com.company.app.common.model.AccountCategory" />
        <mapping class="com.company.app.common.model.AssetType" />
        <mapping class="com.company.app.common.model.Book" />
        <mapping class="com.company.app.model.AssetTypeCategory" />
        <!-- ... -->
    </session-factory>
</hibernate-configuration>

File spring-application-context.xml:

<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="configurationClass">
        <value>org.hibernate.cfg.AnnotationConfiguration</value>
    </property>
    <property name="configLocation">
        <value>classpath:hibernate.cfg.xml</value>
    </property>

    <!-- Instead of the above, I want to use the following. Where and
    how do I define the class mappings so that I may eliminate
    hibernate.cfg.xml? -->
    <--
    <property name="dataSource" ref="dataSource" />
    <property name="mappingResources">
        <list>
            <value>Queries.hbm.xml</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="dialect">org.hibernate.dialect.Oracle10gDialect</prop>
        </props>
    </property>
    -->
</bean>
  • 1 1 Answer
  • 0 Views
  • 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. Editorial Team
    Editorial Team
    2026-05-20T17:10:54+00:00Added an answer on May 20, 2026 at 5:10 pm

    If you’re using JPA-annotated classes, you can use AnnotationSessionFactoryBean instead of LocalSessionFactoryBean, and inject the classes directly into the Spring bean:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
           <list>
               <value>com.company.app.common.model.Account</value>
               <value>com.company.app.common.model.AccountCategory</value>
               <value>com.company.app.common.model.AssetType</value>
               <value>com.company.app.common.model.Book</value>
               <value>com.company.app.model.AssetTypeCategory</value>      
           </list>
        </property>
        <property name="mappingResources">
           <list>
              <value>Queries.hbm.xml</value>
           </list>
        </property>        
        <property name="hibernateProperties">
            <props>
                <prop key="dialect">org.hibernate.dialect.Oracle10gDialect</prop>
            </props>
        </property>
    </bean>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the following exception: org.springframework.orm.hibernate3.HibernateSystemException: Named query not known: Entity class header:
I am using spring/hibernate stand alone application. if i dont configure Transactions i am
I have Hibernate Transaction manager configured inside Spring MVC controller. <bean id=dataSource class=org.apache.commons.dbcp.BasicDataSource destroy-method=close>
I was trying to configure spring 3.1 and hibernate. I have written a simple
Why don't I have any class mappings after calling Configuration.Configure()? Here is my class
I'm trying to persist a very simple class using Hibernate. I'm not using Spring,
I have a Spring, Hibernate, and Wicket application set up to read internationalized json
I have pasted Hibernate 3 configuration file , SessionFactory class to configure this config.xml
I created a simple hello-wordish code using hibernate sf = new Configuration().configure().buildSessionFactory(); System.out.println(sessionFactory is
My DAO's are going to extend the HibernateDaoSupport class that spring provides. Now I

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.