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.  [ 5 posts ] 
Author Message
 Post subject: Need help - Hibernate Dialect must be explicitly set
PostPosted: Fri Jun 23, 2006 12:10 pm 
Newbie

Joined: Fri Jun 23, 2006 12:03 pm
Posts: 2
I'm trying to run the simple Message example.
Here is the Main method:

Configuration cfg = new Configuration();
cfg.addResource("hello/Message.hbm.xml");
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();

Session session = sessions.openSession();
Transaction tx = session.beginTransaction();
Message message = new Message("Hello World");
session.save(message);
tx.commit();
session.close();



Here is the output:

Jun 23, 2006 10:52:21 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.1.3
Jun 23, 2006 10:52:21 AM org.hibernate.cfg.Environment <clinit>
INFO: loaded properties from resource hibernate.properties: {hibernate.c3p0.timeout=300, hibernate.connection.driver_class=org.hsqldb.jdbcDriver, hibernate.cglib.use_reflection_optimizer=true, hibernate.c3p0.max_statements=50, hibernate.c3p0.max_size=20, hibernate.dialect=org.hibernate.dialect.HSQLDialect, hibernate.c3p0.idle_test_period=3000, hibernate.c3p0.min_size=5, hibernate.connection.username=sa, hibernate.connection.url=jdbc:hsqldb:hsql://localhost/testdb, hibernate.connection.provider_class=org.hibernate.connection.C3P0ConnectionProvider, hibernate.connection.password=****}
Jun 23, 2006 10:52:21 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
Jun 23, 2006 10:52:21 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Jun 23, 2006 10:52:21 AM org.hibernate.cfg.Configuration addResource
INFO: Reading mappings from resource: hello/Message.hbm.xml
Jun 23, 2006 10:52:21 AM org.hibernate.cfg.HbmBinder bindRootPersistentClassCommonValues
INFO: Mapping class: hello.Message -> MESSAGES
Jun 23, 2006 10:52:21 AM org.hibernate.connection.UserSuppliedConnectionProvider configure
WARNING: No connection properties specified - the user must supply JDBC connections
Exception in thread "main" 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:378)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:110)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1881)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1174)
at hello.Message.main(Message.java:48)


It seems it loads correct hibernate.properties settings but for some reason didnt initialize it. Any help will be appreciated!


Top
 Profile  
 
 Post subject: Re: Need help - Hibernate Dialect must be explicitly set
PostPosted: Fri Jun 23, 2006 12:19 pm 
Beginner
Beginner

Joined: Sun Jul 10, 2005 12:11 pm
Posts: 32
Location: Hertfordshire, England
IvoBG wrote:
I'm trying to run the simple Message example.
Here is the Main method:

Configuration cfg = new Configuration();
cfg.addResource("hello/Message.hbm.xml");
cfg.setProperties( System.getProperties() );
SessionFactory sessions = cfg.buildSessionFactory();

Session session = sessions.openSession();
Transaction tx = session.beginTransaction();
Message message = new Message("Hello World");
session.save(message);
tx.commit();
session.close();


I've not tried it before, but I think if you do the following:
Code:
Configuration cfg = new Configuration().setProperties(System.getProperties);
cfg.addResource("hello/Message.hbm.xml");
SessionFactory sessions = cfg.buildSessionFactory();      

You should have more luck.

Otherwise, let me know and I'll try to help further.

Christian.

_________________
--
Christian Ashby
Spiralinks, Inc.


Top
 Profile  
 
 Post subject: Re: Need help - Hibernate Dialect must be explicitly set
PostPosted: Fri Jun 23, 2006 12:27 pm 
Newbie

Joined: Fri Jun 23, 2006 12:03 pm
Posts: 2
Hi Christian,

Thank you for the quick response. I tryed it, but the result is the same.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 6:36 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
Did you try and load the HSQLDB driver class manually to see if it's available in the classpath :

In your project environment, add a main method in a class and verify that this code doesn't throw an exception :
Code:
Class.forName("org.hsqldb.jdbcDriver");


What's the result ?

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 23, 2006 6:47 pm 
Senior
Senior

Joined: Sun Jun 04, 2006 1:58 am
Posts: 136
post your hibernate.properties file

_________________
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.