HELP problema com Dialecto MySQL

3 respostas
jonatha_java

bom dia pessoal

espero que me ajudem
estou com um problema para fazer uma aplicação com hibernate anotation funciona, utilizo o mysql 5.1 tenho uma aplicação na qual ela roda normal com mapeamento xml mais quando mudo para o anotationn não funcionar aparece seguinte mensagem erro:

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:256)

at org.hibernate.dialect.Dialect.getDialect(Dialect.java:234)

at org.hibernate.dialect.Dialect.getDialect(Dialect.java:249)

at org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:121)

at org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:91)

at GeraTabelasAnotationn.main(GeraTabelasAnotationn.java:13)

estou usando um hibernate.cfg

<?xml version="1.0" encoding="UTF-8"?> org.hibernate.dialect.MySQLDialect com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/mecanica root 107senha true true
</session-factory>

Classe que gerar as tabelas

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class GeraTabelasAnotationn

{

public static void main(String args[])

{
AnnotationConfiguration cfg = new AnnotationConfiguration();
    cfg.addAnnotatedClass(Pessoa.class);
     SchemaExport  se  = new SchemaExport(cfg);
    se.create(true, true);
}

}

ta faltando alguma coisa? ou estou fazendo errado?

HELP

3 Respostas

jessetsilva

Descomente esta linha:

<!-- <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property> -->

e testa

jonatha_java

ja tentei descomenta não da certo

aqui tambem minha classe que quero que gere a tabela

import java.io.Serializable;

import javax.persistence.Column;

import javax.persistence.Entity;

import <a href="http://javax.persistence.Id">javax.persistence.Id</a>;

import javax.persistence.Table;
@Entity

@Table(name=pessoas)

public class Pessoa implements Serializable {
public Pessoa(){}
@Id
private int id;
@Column
private String nome;
@Column
private String sobreNome;

public int getId() {
    return id;
}

public void setId(int id) {
    this.id = id;
}

public String getNome() {
    return nome;
}

public void setNome(String nome) {
    this.nome = nome;
}

public String getSobreNome() {
    return sobreNome;
}


public void setSobreNome(String sobreNome) {
    this.sobreNome = sobreNome;
}

}

jessetsilva

O problema que ele acusa nao eh da classe a principio.

experimenta ver na documentação do hibernate pelos dialetos disponiveis e testa:

Tenta

org.hibernate.dialect.MySQLDialect

ao inves de

org.hibernate.dialect.MySQLInnoDBDialect
Criado 6 de abril de 2011
Ultima resposta 6 de abr. de 2011
Respostas 3
Participantes 2