-->
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.  [ 6 posts ] 
Author Message
 Post subject: Exception: Hibernate Dialect must be explicitly set
PostPosted: Tue Nov 29, 2005 7:01 pm 
Newbie

Joined: Tue Nov 29, 2005 6:16 pm
Posts: 2
hello,

I'm Hibernate-Newbee and trying to explore all the great things that shall be possible .. and seem to stuck at a trivial problem - but not trivial for me :-(

I'm using
- Eclipse 3.1
- Hibernate Synchronizer 3.1.1 Eclipse Plugin
- Hibernate 3.1
- java SDK 1.5
- SAP DB 7.4
- Windows 2K

installed all - as described in various tutorials - begun creating my first Test Implementation The Eclipse Hibernate Synchronizer Plugin finds my test-DB and generates the hbm.xml, cfg and class files. WOW !

All looks fine, compiling succeeds, I start the Test and ... oops .. get the following error-message
Code:
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:1830)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1150)
   at FirstHibernating.main(FirstHibernating.java:27)


ok !
I check the configuration file(s) and finde two of them:

config.properties: (generated by Hibernate Synchronizer)
Code:
package=db
ConfigFile=\\HiberTest\\src\\db\\hibernate.cfg.xml
databaseUrl=jdbc:sapdb://localhost/testdb01
driver=com.sap.dbtech.jdbc.DriverSapDB
SourceLocation=\\HiberTest\\src
username=test1
dialect=org.hibernate.dialect.SAPDBDialect


hibernate.cfg.xml: (generated by Hibernate Synchronizer)
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
    PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
    <session-factory >

      <!-- local connection properties -->
      <property name="hibernate.connection.url">jdbc:sapdb://localhost/testdb01</property>
      <property name="hibernate.connection.driver_class">com.sap.dbtech.jdbc.DriverSapDB</property>
      <property name="hibernate.connection.username">test1</property>
      <property name="hibernate.connection.password">test1</property>
      <!-- property name="hibernate.connection.pool_size"></property -->

      <!-- dialect for SAP DB -->
        <property name="dialect">org.hibernate.dialect.SAPDBDialect</property>

        <property name="hibernate.show_sql">false</property>
        <property name="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    </session-factory>
</hibernate-configuration>


Both contain a "dialect=org.hibernate.dialect.SAPDBDialect" entry. So
after all it seems, as if Hibernate does not really read (at least one) of these files. I've copied it to nearly every possible (sensful) location e.a. Hibernate home dir, Hibernate lib dir, application bin dir, etc.
Even if I put some senseless text into the configuration files, no error message or something like that appears - that shows me: hibernate does not use these files.

My questions:
- how can I find out, where to put the config files ?
- how can I parametrize hibernate to put a certain file-location? (I've already checked the classpath - locations )
- Is this my problem at all, or has anybody another idea, what the problem could be ??

I've googled the whole Internet .. but the above exception seems to be seldom - in other words : my problem seems to be only my problem :-/

if anybody can help
please let me know

many thanks in advance
.rf.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 29, 2005 11:25 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
what happens when you place hibernate.cfg.xml at the base of the classpath and call Configuration.configure() ... or rename config.properties to hibernate.properties?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 4:24 am 
Beginner
Beginner

Joined: Tue Nov 22, 2005 4:53 pm
Posts: 41
Location: Netherlands
Try setting the property 'hibernate.dialect' instead of only 'dialect'


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 4:42 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
apparently hibernate will append "hibernate" if the dialect property is set w/out it.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 5:12 pm 
Newbie

Joined: Tue Nov 29, 2005 6:16 pm
Posts: 2
Hi Dennis,

IT WORKS!!

Your tip to
Quote:
... call Configuration.configure() ...

helped. The code that I adopted from the Tutorial "Hibernate, a Developers Notebook" written by James Elliot (O Reilly) did not contain this call :-/
Maybe it has to do with the different Hibernate Versions ?!
Anyway !
No I get a "could not get next sequence value" when calling the sesssin.save() Method ... looks as if there is something wrong with key handling ...

Now I'm going to rate your answer ! :-)
Thank you
Ralf F.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 30, 2005 5:28 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Good advise is to not continue with this book (its outdated and has quite a few things that aren't right in it) but start with the "Introduction to Hibernate" tutorial you can find in the latest documentation of Hibernate 3.1 rc3.


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