-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Hibernate Dialect must be explicitly set
PostPosted: Tue Oct 07, 2008 4:16 pm 
Newbie

Joined: Tue Oct 07, 2008 3:55 pm
Posts: 4
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:

Mapping documents:


Code between sessionFactory.openSession() and session.close():
Code:
Initial SessionFactory creation failed. Hibernate Dialect must be explicitly set
Exception in thread "main" java.lang.ExceptionInInitializerError
   at test.TestHibernate1.main(TestHibernate1.java:24)
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
   at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
   at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
   at test.TestHibernate1.main(TestHibernate1.java:19)


Full stack trace of any exception that occurs:
Code:
Initial SessionFactory creation failed. Hibernate Dialect must be explicitly set
Exception in thread "main" java.lang.ExceptionInInitializerError
   at test.TestHibernate1.main(TestHibernate1.java:24)
Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
   at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
   at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
   at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:426)
   at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:128)
   at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2073)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1298)
   at test.TestHibernate1.main(TestHibernate1.java:19)[/img]

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Problems with Session and transaction handling?

Read this: http://hibernate.org/42.html


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 07, 2008 4:26 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
Well, specify the Hibernate dialect in your hibernate properties file (hibernate.cfg.xml or hibernate.properties). It has to be one of these:

DB2 org.hibernate.dialect.DB2Dialect
DB2 AS/400 org.hibernate.dialect.DB2400Dialect
DB2 OS390 org.hibernate.dialect.DB2390Dialect
PostgreSQL org.hibernate.dialect.PostgreSQLDialect
MySQL org.hibernate.dialect.MySQLDialect
MySQL with InnoDB org.hibernate.dialect.MySQLInnoDBDialect
MySQL with MyISAM org.hibernate.dialect.MySQLMyISAMDialect
Oracle (any version) org.hibernate.dialect.OracleDialect
Oracle 9i/10g org.hibernate.dialect.Oracle9Dialect
Sybase org.hibernate.dialect.SybaseDialect
Sybase Anywhere org.hibernate.dialect.SybaseAnywhereDialect
Microsoft SQL Server org.hibernate.dialect.SQLServerDialect
SAP DB org.hibernate.dialect.SAPDBDialect
Informix org.hibernate.dialect.InformixDialect
HypersonicSQL org.hibernate.dialect.HSQLDialect
Ingres org.hibernate.dialect.IngresDialect
Progress org.hibernate.dialect.ProgressDialect
Mckoi SQL org.hibernate.dialect.MckoiDialect
Interbase org.hibernate.dialect.InterbaseDialect
Pointbase org.hibernate.dialect.PointbaseDialect
FrontBase org.hibernate.dialect.FrontbaseDialect
Firebird org.hibernate.dialect.FirebirdDialect

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 08, 2008 3:17 am 
Newbie

Joined: Tue Oct 07, 2008 3:55 pm
Posts: 4
Code:
   <property name="dialect">org.hibernate.dialect.MySQLDialect</property>


This is my configuration file:

Code:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
   <property name="connection.url">jdbc:mysql://localhost/test</property>
   <property name="connection.username">root</property>
   <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
   <property name="connection.password"></property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <!--  thread is the short name for
      org.hibernate.context.ThreadLocalSessionContext
      and let Hibernate bind the session automatically to the thread
    -->
    <property name="current_session_context_class">thread</property>
    <!-- this will show us all sql statements -->
    <property name="hibernate.show_sql">true</property>

   <!-- mapping files -->
   <mapping resource="mywebapp/persistance/data/Article.hbm.xml" />
   <mapping resource="mywebapp/persistance/data/Panier.hbm.xml" />

</session-factory>
</hibernate-configuration>



Top
 Profile  
 
 Post subject: Re: Hibernate Dialect must be explicitly set
PostPosted: Wed Dec 09, 2009 8:34 pm 
Newbie

Joined: Wed Sep 06, 2006 10:35 am
Posts: 14
I was running into this problem using SQLite with Hibernate and JPA. Your solution worked great the first time for very simple select queries. I am keeping my fingers crossed :-)

Thanks for posting this!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.