Pessoal,
estou com um problema estranho aqui…
qnd eu mando rodar a classe q gera o meu banco de dados e deixo a cfg do hibernate em um arquivo hibernate.properties funciona:
hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class org.gjt.mm.mysql.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/xyz
hibernate.connection.username root
hibernate.connection.password
hibernate.show_sql true
hibernate.format_sql true
porem, qnd eu apago e deixo no arquivo .xml ele nao roda:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">org.gjt.mm.mysql.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/xyz</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password"></property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
</session-factory>
</hibernate-configuration>
ERRO:
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:649)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:671)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:86)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:61)
at GerarBanco.main(GerarBanco.java:9)
gostaria de saber o pq?!
estou usando annotations…
Classe gerar banco:
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class GerarBanco {
public static void main(String[] args) {
AnnotationConfiguration conf = new AnnotationConfiguration();
conf.addAnnotatedClass(CategoriaCliente.class);
new SchemaExport(conf).create(true, true);
}
}