macinsmith (3) [Avatar] Offline
I'm running Hibernate 3.1 on Mac OS X, with MySQL 4.0.20 under Eclipse 3.1.1.

I'm trying to run the Hello World example in chapter 2. I created the Message class, the Message.hbm.xml file and a file and I kept getting the error "Hibernate Dialect must be explicitly set". So I copied all of the configuration information that I had put in the properties file and made calls to the Configuration.setProperties class and things worked. I turned on JUnit and found that it reported at INFO Environment:494 it found and read the properties file, so I don't understand why it isn't working. My properties file is shown below:

I'm launching this under a JUnit test.
macinsmith (3) [Avatar] Offline
Re: configuring with hibernate.cfg.xml-- problem solved
Problem solved. I forgot to put the following call in the code.


Once I did, things started working.
jayhawk (2) [Avatar] Offline
Re: configuring with hibernate.cfg.xml-- problem solved
I'm having the same problem, but I'm using the HelloWorld JPA application. In JPA you don't call cfg.confg(). You simply reference a Persistence Unit. Here's my persistence.xml file, which seems correct to me.

[pre]<persistence xmlns="" >
<persistence-unit name="helloworld">
<!-- <br /> The provider only needs to be set if you use several JPA providers <br /> <provider>org.hibernate.ejb.HibernatePersistence</provider> <br /> -->

<!-- This is required to be spec compliant, Hibernate however supports auto-detection even in JSE. -->

<!-- Scan for annotated classes and Hibernate mapping XML files -->
<property name="hibernate.archive.autodetection" value="class, hbm"/>

<!-- SQL stdout logging <br /> <property name="hibernate.show_sql" value="true"/> <br /> <property name="hibernate.format_sql" value="true"/> <br /> <property name="use_sql_comments" value="true"/> <br /> -->

<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.url" value="jdbc:mysql://localhost/hellojpa"/>
<property name="hibernate.connection.username" value="rods"/>
<property name="hibernate.connection.password" value="rods"/>

<property name="hibernate.c3p0.min_size" value="5"/>
<property name="hibernate.c3p0.max_size" value="20"/>
<property name="hibernate.c3p0.timeout" value="300"/>
<property name="hibernate.c3p0.max_statements" value="50"/>
<property name="hibernate.c3p0.idle_test_period" value="3000"/>



As you can see, I'm definitely setting the dialect. I simply replaced the HSQL dialect with a MySQL one. What's wrong with this?
jayhawk (2) [Avatar] Offline
Re: configuring with hibernate.cfg.xml-- problem solved
My problem has been solved. Here's what was wrong in my setup.

I needed to make sure persistence.xml was in the classpath. It wasn't, so Hibernate never found my dialect property.

This begs the question: Why wasn't an error message given about not finding a persistence.xml file?
sethboopathy (1) [Avatar] Offline
Re: configuring with hibernate.cfg.xml-- problem solved
Did not work for me...

I am using Eclipse with ORACLE 10g as backend database
AnirudhVyas (2) [Avatar] Offline
Re: configuring with hibernate.cfg.xml-- problem solved
Hey Boss Seth,

Did you try hibernate.dialect="Oracl10gDialect" ?

and is Persistence.xml in META-INF folder ?

Vyas, Anirudh