Joined: Mon Dec 11, 2006 10:16 pm Posts: 3
|
Hallo everybody!
I'm new member, I'm using hibernate annotation 3.2. I have an error when run my example. I'm implements my example follow document in hibernate annotation 3.2.
This is content of hibernate.cfg.xml
<!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="dialect">org.hibernate.dialect.PostgreSQLDialect</property> <property name="connection.driver_class">org.postgresql.Driver</property> <property name="connection.url">jdbc:postgresql:hibernate</property> <property name="connection.username">postgres</property> <property name="connection.password">postgres</property>
<property name="current_session_context_class">thread</property> <property name="hbm2ddl.auto">update</property> <property name="show_sql">false</property>
<property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.max_size">20</property> <mapping class="ex.Cat"></mapping> </session-factory> </hibernate-configuration>
And HibernateUtil file:
import org.hibernate.*; import org.hibernate.cfg.*;
public class HibernateUtil { private static final SessionFactory sessionFactory; static { try { sessionFactory = new AnnotationConfiguration() .buildSessionFactory(); } catch (Throwable ex) { // Log exception! throw new ExceptionInInitializerError(ex); } }
public static Session getSession() throws HibernateException { return sessionFactory.openSession(); } }
And here is output when run example:
Exception in thread "main" java.lang.ExceptionInInitializerError at util.HibernateUtil.<clinit>(HibernateUtil.java:14) at ex.Test.main(Test.java:8) 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:409) at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119) at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1933) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1216) at util.HibernateUtil.<clinit>(HibernateUtil.java:11) ... 1 more
Anybody help me!
Thanks!
|
|