Hi,
I am trying a small hibernate application using Annotations. However, I am getting an exception when I run the app. Even though I have set the hibernate dialect in my configuration file, I am getting the error below. Can anybody please help me in resolving the error? Thanks in Advance.
Error Details: Exception in thread "main" java.lang.ExceptionInInitializerError at hibernateapp.dao.CasaDao.createEntity(CasaDao.java:19) at hibernateapp.test.TestCasa.main(TestCasa.java:29) 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:2009) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292) at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:915) at hibernateapp.util.SessionFactoryUtil.<clinit>(SessionFactoryUtil.java:26) ... 2 more
This is my hibernate.cfg.xml <?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/samples</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.username">root</property> <property name="connection.password">sairam626</property> <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</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 class="hibernateapp.entity.CASAEntity" /> --> </session-factory> </hibernate-configuration>
Please let me know if you need any details further.
Thanks, Alice
|