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.  [ 1 post ] 
Author Message
 Post subject: Hibernate 3.5.2 unable to use hibernate annotations.
PostPosted: Sun Jun 05, 2011 2:10 pm 

Joined: Sun Jun 05, 2011 1:56 pm
Posts: 2
i created a Message.java with hibernate annotations,but ran it with HelloWorld.java having main method using HQL,
HelloWorld creates sessionfactory using HibernateUtil.java which has this

AnnotationConfiguration cfg = new AnnotationConfiguration();
         SchemaExport schemaExport = new SchemaExport(cfg);
         schemaExport.create(false, true);
         sessionFactory = cfg.buildSessionFactory();

when i ran this code i get this error.::

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" java.lang.ExceptionInInitializerError
   at persistence.HibernateUtil.<clinit>(HibernateUtil.java:17)
   at hello.HelloWorld.main(HelloWorld.java:17)
Caused by: org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
   at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:289)
   at org.hibernate.dialect.Dialect.getDialect(Dialect.java:267)
   at org.hibernate.dialect.Dialect.getDialect(Dialect.java:282)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:121)
   at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:91)
   at persistence.HibernateUtil.<clinit>(HibernateUtil.java:13)
   ... 1 more

this is the hibernate.cfg.xml am using::

<!DOCTYPE hibernate-configuration SYSTEM
<property name="hibernate.connection.driver_class">
<property name="hibernate.connection.url">
<property name="hibernate.connection.username">
<property name="hibernate.dialect">
<!-- Use the C3P0 connection pool provider   -->
<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<!-- Show and print nice SQL on stdout
<property name="show_sql">true</property>
<property name="format_sql">true</property>  -->

<!-- List of XML mapping files
<mapping resource="hello/Message.hbm.xml"/> -->

<!-- List of annotated classes-->
<mapping class="hello.Message"/>


could you please tell me why am getting this error?Itried run this code without annotations i.e using hbm.xml and it worked smooth.

Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.