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

  • Home
  • SEARCH
  • 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 8599755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:27:53+00:00 2026-06-12T01:27:53+00:00

Want to clear some confusion. I have applicationContext.xml. Question 1: Whats the difference between

  • 0

Want to clear some confusion. I have applicationContext.xml.

Question 1: Whats the difference between 1 & 2. Are they both same with different approach?

Question 2:

I asked question on Spring forum regarding some problem. Onething he mentioned about pooling is below

if you need/want to use the internal connection pooling for hibernate
I would advice against it and simply configure a datasource which
supports connection pooling and inject that into your
sessionfactorybean.

internal connection pooling for hibernate = This is number 2 below. Right?

simply configure a datasource which supports connection pooling and inject that into your sessionfactorybean = This is number 1 below. right?

1# –

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <property name="maxActive" value="100"/>
        <property name="maxIdle" value="30"/>
        <property name="maxWait" value="16000"/>
        <property name="minIdle" value="0"/>
    </bean>

 <!-- Hibernate SessionFactory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="annotatedClasses">
            <list>
                <value>com.mkyong.customer.model.Customer</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">false</prop>
                <prop key="hibernate.generate_statistics">true</prop>
            </props>
        </property>
    </bean>

2# –

Pooling and connection info is in hibernate.cfg.xml

<bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="configLocation" value="classpath:hibernate.cfg.xml" />
    </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-06-12T01:27:54+00:00Added an answer on June 12, 2026 at 1:27 am

    Answer 1:

    Both approaches are the same. By default , hibernate reads the configuration from classpath:hibernate.cfg.xml to build SessionFactory . LocalSessionFactoryBean just allows you to setup hibernate configuration inside applicationContext.xml instead of hibernate.cfg.xml .

    If a same property is specified in both files , depending on the property , it will has addictive effect or the properties specified in applicationContext.xml will take higher priority such that those values in hibernate.cfg.xml will be ignored.

    For method 1, annotatedClasses and hibernateProperties should have the addictive effect with the corresponding values in hibernate.cfg.xml . The DBCP dataSouruce in applicationContext.xml should cause the related properties in hibernate.cfg.xml being ignored.

    Answer 2:

    For method 2 , if you don’t specify any properties of LocalSessionFactoryBean , all the hibernate configurations are specified by the hibernate.cfg.xml. If there are no connection pool configured in hibernate.cfg.xml , hibernate’s own connection pooling algorithm is used by default , which is quite rudimentary and not intended for use in a production system, or even for performance testing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just a quick question to clear up some confusion that I have regarding units
I have a slightly theoretical question that I want to clear up before I
Could someone help me clear up some confusion... I want to put in some
I want to clear the contents of some std::list . The order of removing
after some confusion in the comments to Is it safe to have 1 letter
It took me quite a bit of experimentation to clear up some confusion over
I want to have some data cache which contains some objects which I can
I've some clear text which I want to encrypt using RSA_PKCS_V21 (using PolarSSL library).
I want to draw some text onto my canvas and want to clear everything
EDIT: My example might have created some confusion. I have changed the example below

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.