title: MyBatis with postgres throws "ERROR: relation "dual" does not exist"
body: <p>I am using MyBatis to do a very simple select in a postgres database in a java web based application</p>
  
  <p>Setup is as follows:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
          &lt;artifactId&gt;mybatis&lt;/artifactId&gt;
          &lt;version&gt;3.2.3&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.mybatis&lt;/groupId&gt;
          &lt;artifactId&gt;mybatis-spring&lt;/artifactId&gt;
          &lt;version&gt;1.2.2&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>And the the following driver:</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;9.2-1004-jdbc41&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>The mapper looks as follows:</p>
  
  <pre><code>&lt;select id="getLicenseUsage"  parameterType="long"  resultMap="licenseUsage"&gt;
      select ('1970-01-01 00:00:00 GMT'::timestamp + (event_time/1000)::text::interval)::date as day, license_key, count(distinct event_id) as recos, max(id) as venm_id
      from venm_raw
      where target_id is not null and id &gt; #{fromId}
      group by license_key,day;
  &lt;/select&gt;
  </code></pre>
  
  <p>When i execute this query i get the following error: </p>
  
  <pre><code>"ERROR: relation "dual" does not exist"
  </code></pre>
  
  <p>From the different readings over the net, it seems that MyBatis is looking behind the scenes for a table named "dual" which exists in Oracle but not in postgres. This is just a guess at this point.</p>
  
  <p>I am stuck here, help s much appreciated. Thx in advance.</p>
  
  <p>Full trace below:</p>
  
  <pre><code>org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
  ### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ERROR: relation "dual" does not exist)
  ### The error may exist in file [/opt/tomcat/webapps/ROOT/WEB-INF/classes/META-INF/mappers/redshift/LicenseUsageMapper.xml]
  ### The error may involve com.qualcomm.vuforia.redshift.mappers.LicenseUsageMapper.getLicenseUsage
  ### The error occurred while executing a query
  ### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ERROR: relation "dual" does not exist)
          at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
          at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:371)
          at com.sun.proxy.$Proxy36.selectList(Unknown Source)
          at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
          at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
          at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
          at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
          at com.sun.proxy.$Proxy49.getLicenseUsage(Unknown Source)
          at com.qualcomm.vuforia.sumtables.summarizers.SummarizerProcessor.process(SummarizerProcessor.java:60)
          at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)
  </code></pre>