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: Hibernate using annotations
PostPosted: Mon Dec 11, 2006 1:08 pm 

Joined: Mon Dec 11, 2006 9:22 am
Posts: 7

I'm trying to use hibernate with Annotations but I really don't get it to work. :(

I started with the tutorial which worked well, but uses the old hbm.xml-files rather than annotations.

So I used the Manual to make it use annotations.

I added the required libraries, annotated the class with Entity, changed the hibernate.cfg.xml to uste mapping-class and used AnnotationConfiguration to generate the session-factory.

Starting the programm (which worked before) now results in an error:

[java] 14:39:15,604  WARN UserSuppliedConnectionProvider:23 - No connection properties specified - the user must supply JDBC connections
     [java] Initial SessionFactory creation failed.org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
     [java] Exception in thread "main" java.lang.ExceptionInInitializerError
     [java] at util.HibernateUtil.<clinit>(Unknown Source)
     [java] at events.EventManager.createAndStoreEvent(Unknown Source)
     [java] at events.EventManager.main(Unknown Source)
     [java] Caused by: org.hibernate.HibernateException: Hibernate Dialect must be explicitly set
     [java] at org.hibernate.dialect.DialectFactory.determineDialect(DialectFactory.java:57)
     [java] at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:39)
     [java] at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
     [java] at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
     [java] at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2006)
     [java] at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1289)
     [java] ... 3 more
     [java] Java Result: 1

The rerevant Part from the hibernate.cfg.xml is probably:
        <property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
        <property name="connection.url">jdbc:hsqldb:hsql://localhost</property>
        <property name="connection.username">sa</property>
        <property name="connection.password"></property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.HSQLDialect</property>
      <mapping class="events.Event"/>

Any Idea what could be wrong there?
Is it correct to specify the database in the config file?
(What would be a better place otherwise?)

Is there a complete example somewhere? (I really couldn't find one with google.)

Thanks in Advantage.
(References to better documentation are gladly welcome.)

 Post subject:
PostPosted: Mon Dec 11, 2006 9:16 pm 

Joined: Tue Oct 10, 2006 3:23 am
Posts: 33
The property for the dialect is hibernate.dialect not dialect

**Rate if this helped

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.