title: Concurrent @Transactional method calls do not really happen concurrently
body: <p>I have a test that starts 40 threads concurrently which each of them run the same method.</p>
  
  <p>Without @Transactional annotation on that method, the method calling time is more or less the same in all threads. (even down to milliseconds level)</p>
  
  <p>With @Transactional, the method calls are kind of in sequence! (Each method call has about 0.1 sec delay).</p>
  
  <p>So why is it so?</p>
  
  <p>Actually I am testing the isolation level, with such test to see if dirty read can occur with level READ_UNCOMMITTED.</p>
  
  <p>But such delay simply make the queries/transactions not concurrent!</p>
  
  <pre><code>public void saveOrUpdateRecord(Record record) throws NoAvailableRecordException {
  LOGGER.debug("saveOrUpdateRecord called");
  int currentPoolSize = recordDao.getActiveRecordSize(record
      .getCreatedTime());
  LOGGER.debug("saveOrUpdateRecord:: currentPoolSize: " + currentPoolSize);
  if (currentPoolSize &gt;= 30) {
    throw new NoAvailableRecordException();
  }
  
  recordDao.save(record);}
  </code></pre>
  
  <p>This is the function called.</p>
  
  <p>Below are the DAO function,</p>
  
  <pre><code>public int getActiveRecordSize(Date asOfTime) throws DataAccessException {
  String hql = "from Record record where record.expiryTime &gt; :asOfTime";
  return this.getHibernateTemplate()
      .findByNamedParam(hql, "asOfTime", asOfTime).size();}
  
  
  
  
  public void save(Record record) throws DataAccessException {
  try {
    this.getHibernateTemplate().save(record);
    this.getHibernateTemplate().flush();
  } catch (HibernateException hex) {
    throw this.convertHibernateAccessException(hex);
  }}
  </code></pre>
  
  <p>Answers and suggestions are very welcomed. :)</p>