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: problem with using SchemaExport class with annotated classes
PostPosted: Sat Nov 18, 2006 8:47 am 
Newbie

Joined: Fri Nov 17, 2006 7:24 pm
Posts: 16
Thank you for reading my post
I have problem in SchemaExport class to export schema of some annotated class.
I am trying some code from a book, but it looks to have some problems.
I add all source code that are required here.


Hibernate version: 3.2
Name and version of the database you are using: MySQL 5

hibernate configuration file:
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>






Full stack trace of any exception that occurs:
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:25)







Code:
package learn_hiber.chapter4;

import java.io.File;
import java.io.IOException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class GenerateSchema
{
public String printURL(){
   
    return this.getClass().getResource("/learn_hiber/hibernate.cfg.xml").getPath();
}
    public static void main(String[] args)
    {
        GenerateSchema gn = new GenerateSchema();
       
       // Amended to allow a path (to the hibernate.cfg.xml) to
       // be passed to the configuration.
        AnnotationConfiguration cfg = ExampleConfiguration.getConfig();;
       
        System.out.println(gn.printURL());
        cfg.addFile(new File(gn.printURL()));
        SchemaExport schemaExport = new SchemaExport(cfg);
        schemaExport.create(true, true);
    }
}


Top
 Profile  
 
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.