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