title: select into outfile not working with hibernate
body: <p>I am trying to execute de following code in Hibernate to create a .csv file from a mySQL database. :</p>
  
  <pre><code>String sql = 
  "SELECT * INTO OUTFILE 'table.csv' FIELDS TERMINATED BY ','" +
  " OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n' " +
  "FROM match INNER JOIN totala ON match_code= match";
  </code></pre>
  
  <p>The .csv file is created correctly but then I get the following error:</p>
  
  <pre><code>Exception monitoring the input folder org.hibernate.exception.GenericJDBCException: could not execute query
      at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
      at org.hibernate.loader.Loader.doList(Loader.java:2452)
      at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2192)
      at org.hibernate.loader.Loader.list(Loader.java:2187)
      at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
      at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1832)
      at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
      at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:179)
      at com.salebuild.dao.hibernate.CorporateTitleDAOImpl.dumpTitleCompanyCSV(CorporateTitleDAOImpl.java:49)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)
      at $Proxy128.dumpTitleCompanyCSV(Unknown Source)
      at com.salebuild.service.CorporateTitleServiceImpl.dumpTitleCompanyCSV(CorporateTitleServiceImpl.java:53)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)
      at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
      at $Proxy159.dumpTitleCompanyCSV(Unknown Source)
      at com.salebuild.service.collector.ContactScraperMonitorInputFolder.addNewFile(ContactScraperMonitorInputFolder.java:61)
      at com.salebuild.service.collector.ContactScraperMonitorInputFolder.run(ContactScraperMonitorInputFolder.java:37)
      at java.lang.Thread.run(Thread.java:619)
  Caused by: java.sql.SQLException: ResultSet is from UPDATE. No Data.
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
      at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
      at com.mysql.jdbc.ResultSetImpl.next(ResultSetImpl.java:7021)
      at com.mchange.v2.c3p0.impl.NewProxyResultSet.next(NewProxyResultSet.java:2859)
      at org.hibernate.loader.Loader.doQuery(Loader.java:741)
      at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:270)
      at org.hibernate.loader.Loader.doList(Loader.java:2449)
      ... 29 more
  </code></pre>
  
  <p>Some googling suggested that it may be because query is not returning any result so I get "java.sql.SQLException: ResultSet is from UPDATE. No Data". But how do I get over this exception.I dont want my code to break.</p>
  
  <p>I am running the query like:</p>
  
  <pre><code>public void dumpTitleCompanyCSV(String titleId,String titleName, String dumpFolder) {
          Session session = getSession();
          String hql = "SELECT "+titleId+" ,id, \""+titleName+"\", name " +
                      "FROM company INTO OUTFILE 'd:/contact/input/file.csv' " +
                      "FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n'";
          logger.debug("jeets The query is \n "+hql);
          Query query  = session.createSQLQuery(hql);
           query.list();
      }
  </code></pre>