title: Hibernate dialect for Hive/SparkSQL?
body: <p>I have an app that used to connect to <code>MySQL</code>, and I have <code>Hibernate</code> config
  for it like this:</p>
  
  <pre><code>&lt;hibernate-configuration&gt;
     &lt;session-factory&gt;
         &lt;property name="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/property&gt;
         &lt;property name="hibernate.connection.driver_class"&gt;com.mysql.jdbc.Driver&lt;/property&gt;
         &lt;property name="hibernate.connection.url"&gt;jdbc:mysql://somehost:3306/some_db&lt;/property&gt;
         ...
  </code></pre>
  
  <p>Now if I want to connect to <code>Hive/SparkSQL</code> instead, what would the 
  equivalent values for these properties be?</p>
  
  <p>I have some ideas on <code>driver_class</code> and <code>url</code> (assuming we are using port <code>10000</code>), but what should the <code>dialect</code> be?</p>
  
  <pre><code>&lt;property name="hibernate.connection.driver_class"&gt;org.apache.hive.jdbc.HiveDriver&lt;/property&gt;
  &lt;property name="hibernate.connection.url"&gt;jdbc:hive2://someHost:10000&lt;/property&gt;
  </code></pre>
  
  <p><strong>Update</strong></p>
  
  <p>I tried many different values but none of them work. (I have yet 
  to find out what metastore the Apache Hive installation uses, so here
  I was just doing trial-and-error)</p>
  
  <pre><code>org.hibernate.dialect.MySQLDialect
  org.hibernate.dialect.MySQLInnoDBDialect
  org.hibernate.dialect.DerbyDialect
  org.hibernate.dialect.DerbyTenFiveDialect
  org.hibernate.dialect.Oracle10gDialect
  org.hibernate.dialect.H2Dialect
  org.hibernate.dialect.Dialect
  </code></pre>
  
  <p>I noticed that in all case, there is a warning from 
  Hibernate that said:</p>
  
  <pre><code>WARN JdbcServicesImpl,main:160 - \
    HHH000341: Could not obtain connection metadata : \
    Method not supported
  </code></pre>
  
  <p>And then the code would run into a <code>NullPointerException</code><br>
  in <code>org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure()</code> 
  (Line 207 in 4.2.0.Final).</p>
  
  <p>I downloaded the source code of Hibernate and traced the logic.
  The exception was caused because a few line ahead a variable
  <code>dialect</code> (of type <code>Dialect</code>) was determined to be <code>null</code> due to 
  an exception caught when trying to execute Line 138:</p>
  
  <pre><code>metaReportsDDLCausesTxnCommit = meta.dataDefinitionCausesTransactionCommit();
  </code></pre>
  
  <p>The exception was</p>
  
  <pre><code>java.sql.SQLException: Method not supported
  </code></pre>
  
  <p>(that caused the above warning message) </p>
  
  <p>Does that mean I cannot use <code>Hibernate</code> with Apache Hive?
  If that is the case, then so be it.  (I guess I would have
  to swap out the <code>Hibernate</code> implementation for this part)
  But I am curious to know the authoritative answer
  on this.</p>
  
  <p>On the Internet I could not find strong evidence that 
  people have been using <code>Hibernate</code> successfully with Apache Hive.</p>