Hi
Thank you for reading my post.
can some one please help me with this problem?
I am trying to generate database schema using hibernate schema export features.
I should say that i have annotated java classes which i want to generate schema from them.
Hibernate version: 3.2
Mapping documents:
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>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://127.0.0.1/learnHiberDB</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<mapping package="learn_hiber.chapter4"/>
<mapping class="learn_hiber.chapter4.Author"/>
<mapping class="learn_hiber.chapter4.Book"/>
<mapping class="learn_hiber.chapter4.ComputerBook"/>
<mapping class="learn_hiber.chapter4.Publisher"/>
</session-factory>
</hibernate-configuration>
Code that i used to generate schema.Code:
package learn_hiber.chapter4;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class GenerateSchema
{
public static void main(String[] args)
{
// Amended to allow a path (to the hibernate.cfg.xml) to
// be passed to the configuration.
AnnotationConfiguration cfg = ExampleConfiguration.getConfig();;
SchemaExport schemaExport = new SchemaExport(cfg);
schemaExport.create(true, true);
}
}
[exception that i get]
Code:
Exception in thread "main" org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:635)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:657)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:84)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:59)
at learn_hiber.chapter4.GenerateSchema.main(GenerateSchema.java:18)
Java Result: 1
Example configuration that i usedCode:
package learn_hiber.chapter4;
import org.hibernate.cfg.AnnotationConfiguration;
public class ExampleConfiguration
{
public static AnnotationConfiguration getConfig() {
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Author.class);
cfg.addAnnotatedClass(Book.class);
cfg.addAnnotatedClass(ComputerBook.class);
cfg.addAnnotatedClass(Publisher.class);
return cfg;
}
}
can some one please tell me what i am doing wrong?
Thanks