-->
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.  [ 2 posts ] 
Author Message
 Post subject: Dialect not set
PostPosted: Fri May 20, 2005 12:20 am 
Newbie

Joined: Thu May 19, 2005 11:50 pm
Posts: 10
First off, I'm a Hibernate newbie. I'm running it through Eclipse and, to start, without using an application server. Basically I'm trying to just run it by calling a pojo class with a main method. Unfortunately, I keep getting an error that the dialect is not set. I have hibernate3.jar as one of my libraries. I list "org.hibernate.dialect.SQLServerDialect" in my hibernate.cfg.xml file and that class does exist (which I can tell by expanding the jar file in Eclipse). For a sanity check I tried renaming hibernate.cfg.xml to make sure that I got a runtime error saying that file wasn't found (it wasn't). I checked google and I didn't see anything that I thought would help me so I feel compelled to ask on this forum. I would greatly appreciate any help in getting my feet on the ground here. There's nothing more frustrating than configuration issues. I can't get into the heart of Hibernate until I can get past this problem. Thanks in advance.


Hibernate version: 3.0

Mapping documents:

THIS IS hibernate.cfg.xml...

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

<hibernate-configuration>
<session-factory name="myFactory">
<property name="show_sql">true</property>


<property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sqlserver://localhost:1433/Registration;user=myuser;password=mypassword;TDS=7.0;</property>
<property name="connection.username">myUser</property>
<property name="connection.password">myPassword</property>

<property name="hbm2ddl.auto">update</property>

<property name="hibernate.cglib.use_reflection_optimizer">false</property>

<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">11</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">10</property>

<mapping resource="com/test/beans/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>



Code between sessionFactory.openSession() and session.close():
package com.test.tests;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateTest {
public static void main (String[] args) {
Configuration cfg = new Configuration();
cfg.configure();
cfg.setProperties(System.getProperties());
SessionFactory sessions = cfg.buildSessionFactory();
}
}



Full stack trace of any exception that occurs:
May 20, 2005 12:13:01 AM org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.0 beta 3
May 20, 2005 12:13:01 AM org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
May 20, 2005 12:13:01 AM org.hibernate.cfg.Environment <clinit>
INFO: using CGLIB reflection optimizer
May 20, 2005 12:13:01 AM org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
May 20, 2005 12:13:01 AM org.hibernate.cfg.Configuration configure
INFO: configuring from resource: /hibernate.cfg.xml
May 20, 2005 12:13:01 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: Configuration resource: /hibernate.cfg.xml
May 20, 2005 12:13:01 AM org.hibernate.cfg.Configuration addResource
INFO: Mapping resource: com/test/User.hbm.xml
May 20, 2005 12:13:01 AM org.hibernate.cfg.HbmBinder bindRootClass
INFO: Mapping class: com.test.User -> USER
May 20, 2005 12:13:02 AM org.hibernate.cfg.Configuration doConfigure
INFO: Configured SessionFactory: myFactory
May 20, 2005 12:13:02 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing extends queue
May 20, 2005 12:13:02 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing collection mappings
May 20, 2005 12:13:02 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing association property references
May 20, 2005 12:13:02 AM org.hibernate.cfg.Configuration secondPassCompile
INFO: processing foreign key constraints
Exception in thread "main" org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:461)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:483)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:50)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1474)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1018)
at com.test.tests.HibernateTest.main(HibernateTest.java:11)


Name and version of the database you are using:
MSSQL 7.0


The generated SQL (show_sql=true):
None


Debug level Hibernate log excerpt: ???


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 1:34 am 
Newbie

Joined: Mon Apr 11, 2005 2:08 pm
Posts: 8
I would try to remove the following line of code:

Code:
cfg.setProperties(System.getProperties());


see javadoc of Configuration.setProperties:

Code:
Specify a completely new set of properties


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