Hallo,
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:
Code:
[...]
[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:
Code:
<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.)