-->
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: Simple Problem That I could never figure...hibernate.cfg.xml
PostPosted: Mon Apr 04, 2005 1:04 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
Hibernate version: 3.0RC1


Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>

<class name="hello.Message" table="MESSAGES">
<id name="id" column="MESSAGE_ID" access="field">
<generator class="native"/>
</id>

<property name="text" column="MSG_TXT"/>

<many-to-one name="nextMessage" column="NEXT_MSG_ID"/>
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:
13:00:28,178 INFO Environment:456 - Hibernate 3.0rc1
13:00:28,191 INFO Environment:469 - hibernate.properties not found
13:00:28,197 INFO Environment:502 - using CGLIB reflection optimizer
13:00:28,206 INFO Environment:532 - using JDK 1.4 java.sql.Timestamp handling
13:00:28,208 DEBUG Configuration:1035 - Preparing to build session factory with filters : {}
13:00:28,214 INFO Configuration:844 - processing extends queue
13:00:28,228 INFO Configuration:848 - processing collection mappings
13:00:28,230 INFO Configuration:857 - processing association property references
13:00:28,232 INFO Configuration:884 - processing foreign key constraints
Exception in thread "main" java.lang.ExceptionInInitializerError
at hello.HelloWorld.<clinit>(HelloWorld.java:38)
Caused by: org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:474)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:496)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:51)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1497)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1041)
at hello.HelloWorld.<clinit>(HelloWorld.java:34)

Name and version of the database you are using:
HSQLDB (latest)
The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:
DEBUG


I have run into this problem in previous applications -- so I just created a hibernate.properties file and it would work. But my understanding is that this properties file is going away. For some reason my hibernate.cfg.xml is never picked up when I put it in the src directory -- it is first in my classpath when I run the HelloWorld example.

Could this have anything to do with me being on a mac running OS X?

Here is my hibernate.cfg.xml file:

<!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="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
<property name="hibernate.connection.url">jdbc:hsqldb:hello</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">create</property>

<mapping resource="hello/Message.hbm.xml"/>
</session-factory>

</hibernate-configuration>

Any help is greatly appreciated -- I have training tomorrow and I was walking through the CBT and I hit this config issue again.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 1:15 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Do you use the HibernateUtil class and is your startup call "new Configuration().configure().buildSessionFactory()"?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 1:21 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
Hi there:-)

No not on the CBT am I using the HibernateUtil class -- although I am familiar with it from other projects.

Yes my code is as such:

sessionFactory = new Configuration().buildSessionFactory();

It is exactly as you outlined in your CBT :-)

Thank you for any help.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 1:48 pm 
Newbie

Joined: Thu Sep 02, 2004 8:41 pm
Posts: 11
Thank you Sir! ...
I as can be seen above ... I did not call configure().

This api call slipped by me ... it states it right in the javadoc ... sorry and thank you for your time.


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.