Pessoal estava tentando seguir um tutorial para começar a utilizar o hibernate mas esta dando o seguinte erro
08/01/2010 09:55:11 org.hibernate.cfg.annotations.Version <clinit>
INFO: Hibernate Annotations 3.3.1.GA
08/01/2010 09:55:11 org.hibernate.cfg.Environment <clinit>
INFO: Hibernate 3.2.5
08/01/2010 09:55:11 org.hibernate.cfg.Environment <clinit>
INFO: hibernate.properties not found
08/01/2010 09:55:11 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: Bytecode provider name : cglib
08/01/2010 09:55:11 org.hibernate.cfg.Environment <clinit>
INFO: using JDK 1.4 java.sql.Timestamp handling
Exception in thread "main" org.hibernate.HibernateException: The dialect was not set. Set the property hibernate.dialect.
at org.hibernate.dialect.Dialect.instantiateDialect(Dialect.java:233)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:211)
at org.hibernate.dialect.Dialect.getDialect(Dialect.java:226)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:86)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:61)
at pessoas.Teste.main(Teste.java:19)
Java Result: 1
andei dando uma pesquisada já tentei trocar o dialect para “org.hibernate.dialect.MySQLDialect”, “org.hibernate.dialect.MySQLInnoDBDialect” e “org.hibernate.dialect.MySQLMyISAMDialect” e não funcionou.
Segue meu código
<?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.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/pessoas</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">123456</property>
</session-factory>
</hibernate-configuration>
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pessoas;
import javax.persistence.*;
/**
*
* @author g8si
*/
@Entity
public class Pessoa {
@Id
@GeneratedValue
private int id;
private String nome;
private int idade;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getIdade() {
return idade;
}
public void setIdade(int idade) {
this.idade = idade;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package pessoas;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
/**
*
* @author g8si
*/
public class Teste {
public static void main(String args[]){
AnnotationConfiguration cfg = new AnnotationConfiguration();
cfg.addAnnotatedClass(Pessoa.class);
SchemaExport se = new SchemaExport(cfg);
se.create(true, true);
}
}
As bibliotecas que importei são as seguintes
