How session is handling multiple request with SpringMVC and hiberate
<p>I am having an application with a transfer table,where user can transfer money from one person to another.I am using spring MVC with hibernate to create web services.I am understanding that when multiple people sends request through the same web service,multiple threads will be created by dispatcher servlet.Now it each thread will to go respective web method defined in controller class.Now i am having a daoImplementation  class which i have autowired with controller class. Now each request thread will use the autowired daoImplementation object to access daoImplementation class method.
Now my 1st doubt-
How one daoImplementation object(its singleton) can handle multiple requests?if suppose thousand people are sending request that need to access daoImplementation class method which takes 10 sec for each request then the delays for 1000th request will be 10000 sec.</p>

<p>Now, after that request went inside daoImplementation method which will do database work.In daoImplementation class i have autowired SessionFactory which is also singleton and thread safe(that means for each request it will create one session thread).In my method i am creating session object to do my transactions.
Now my second doubt-
Suppose thousand people are trying to access same method in daoImplementation class, so 1000 session object will be created.How these thousand object will interact with database so that there will be not much delay in each request and how the databse will maintain consistency?
Also session is thread safe,how it will impact my system.</p>

<p>Now my third doubt-
For transfer,first i need to get the current amount present in sender account,then check whether it is less than the amount he is wanting to transfer to receiver account,then deduct that much amount from sender account and then add that much amount in receiver account and then close the session.Being a beginner i will write my code like this-</p>

<pre><code>    public class CommonDAOImpl{
    private SessionFactory sessionFactoryCommon;
    public void setSessionFactoryCommon(SessionFactory sessionFactoryCommon) {
        this.sessionFactoryCommon = sessionFactoryCommon;
        System.out.println("SessionFactory is set");
    }
    public void addMoney(String userId,double amount) {
        Session session = this.sessionFactoryCommon.openSession();
        try{
            String hqlQuery = "HQL query to update Amount Table where userId = userId";
            session.createQuery(hqlQuery).executeUpdate();
        }
        catch(Exception ex)
        {
            ex.printStackTrace();
        }
        finally
        {
            session.close();
        }
    }
    public void transferMoney(String fromUserId, String toUserId, double amount)
    {

        Session session = null;
        try
        {
            session = this.sessionFactoryCommon.openSession();
            query = "HQL query to get previous amount from sender account";
            double prevSenderamount = (double) query.uniqueResult();
      if(prevAmount&gt;=amount)
      {
        String query1 = "HQL query to update sender account";
        session.createQuery(hqlQuery).executeUpdate();
        String query1 = "HQL query to get previous amount from receiver account";
        double prevReceiveramount = (double) query.uniqueResult();
        String query3 = "HQL query to update receiver account";
        session.createQuery(hqlQuery).executeUpdate();
      }
      else
      {
        throw myException("Insufficient Amount"); 
      }

            System.out.println("1. Employee save called without transaction, id="+id);
        }
        catch(Exception ex)
        {
            System.out.println("Exception Block");
            ex.printStackTrace();
        }
        finally
        {
            session.close();
        }
    }
}
</code></pre>

<p>Is this correct way to do database calls?
Please try to explain in simplified way-
Thank you in advance.</p>