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
Code:
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.::
Code:
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::
Code:
<!DOCTYPE hibernate-configuration SYSTEM
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">
org.hsqldb.jdbcDriver
</property>
<property name="hibernate.connection.url">
jdbc:hsqldb:hsql://localhost/
</property>
<property name="hibernate.connection.username">
SA
</property>
<property name="hibernate.dialect">
org.hibernate.dialect.HSQLDialect
</property>
<!-- 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"/>
</session-factory>
</hibernate-configuration>
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.