title: MyBatis hangs when inserting
body: <p>I am trying to insert a record into Oracle 11g database using MyBatis-Spring, but the insert hangs. Select works fine.</p>
  
  <p>I need another set of eyes to help me figure out what is going on.</p>
  
  <p>Here are the snippets of codes that matter:</p>
  
  <p><strong>Logging output: (it hangs forever on the last line)</strong></p>
  
  <pre><code>Running persistence.PartyMapperUnitTest
  DEBUG [main] - Cache Hit Ratio [persistence.mapper.PartyMapper]: 0.0
  DEBUG [main] - ==&gt;  Preparing: SELECT PARTY_ID, PARTY_SUBTYPE_CD, LIFECYCLE_CD, PARTY_STATUS_CD FROM PARTY WHERE PARTY_ID =2 
  DEBUG [main] - ==&gt; Parameters: 
  DEBUG [main] - &lt;==      Total: 1
  DEBUG [main] - ==&gt;  Preparing: INSERT INTO PARTY (PARTY_SUBTYPE_CD, LIFECYCLE_CD, PARTY_STATUS_CD, CREATED_BY) VALUES (?,?,?,?) 
  DEBUG [main] - ==&gt; Parameters: partySubtypeCode1438810529048(String), lifecycleCode(String), partyStatusCode(String), createdBy(String)
  ***==== The application hangs forever at this log line ====***
  </code></pre>
  
  <p><strong>Testing.sql</strong> (this works fine)</p>
  
  <pre><code>INSERT INTO PARTY (PARTY_SUBTYPE_CD, LIFECYCLE_CD, PARTY_STATUS_CD, CREATED_BY)
  VALUES ( 'a', 'b', 'c', 'd');
  </code></pre>
  
  <p><strong>applicationContext.xml</strong></p>
  
  <pre><code>&lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p><strong>PartyMapper.java</strong></p>
  
  <pre><code>public interface PartyMapper&lt;PartyEntity&gt; {
      public PartyEntity fetch(Object entityId);
      public int insert(PartyEntity entity);
  }
  </code></pre>
  
  <p><strong>PartyMapper.xml</strong></p>
  
  <pre><code>&lt;insert
      id="insert"
      parameterType="persistence.entity.PartyEntity"
      keyProperty="partyId"
      keyColumn="PARTY_ID"
      useGeneratedKeys="true"&gt;
      INSERT INTO PARTY
          (PARTY_SUBTYPE_CD, LIFECYCLE_CD, PARTY_STATUS_CD, CREATED_BY)
      VALUES
          (#{partySubtypeCode},#{lifecycleCode},#{partyStatusCode},#{createdBy})
  &lt;/insert&gt;
  </code></pre>
  
  <p><strong>PartyMapperUnitTest.java</strong></p>
  
  <pre><code>PartyEntity expectedParty = new PartyEntity();
  expectedParty.setPartySubtypeCode("a");
  expectedParty.setLifecycleCode("b");
  expectedParty.setPartyStatusCode("c");
  expectedParty.setCreatedBy("d");
  partyMapper.insert(expectedParty);
  </code></pre>
  
  <p><strong>=== EDIT ===</strong>
  There are only two threads running when the UnitTest runs. I don't see anything wrong in here.</p>
  
  <p>Added a Thread.dumpStack() before the insert, but did not see anything wrong with it:</p>
  
  <p><strong>Thread.dumpStack()</strong></p>
  
  <pre><code>INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@77ab3f0: defining beans [transactionManager,org.springframework.aop.config.internalAutoProxyCreator,org.springframework.transaction.annotation.AnnotationTransactionAttributeSource#0,org.springframework.transaction.interceptor.TransactionInterceptor#0,org.springframework.transaction.config.internalTransactionAdvisor,sqlSessionFactory,dataSource,org.mybatis.spring.mapper.MapperScannerConfigurer#0,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,mapper,partyMapper,org.springframework.context.annotation.ConfigurationClassPostProcessor$ImportAwareBeanPostProcessor#0]; root of factory hierarchy
  java.lang.Exception: Stack trace
      at java.lang.Thread.dumpStack(Thread.java:1365)
      at td.com.naccms.cps.persistence.PartyMapperUnitTest.insert(PartyMapperUnitTest.java:48)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:606)
      at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
  ...
  ...
  </code></pre>