Erro ao gerar tabelas com Hibernate [RESOLVIDO]

1 resposta
ibotirama

Eu pesquisei tópicos no fórum, mas as dicas encontradas não funcionaram, e as minhas tabelas não estão sendo geradas e também não dá erro nenhum, aparece tudo bonitinho como se estivesse ok.

Alguém poderia dar uma ajuda por favor. :roll:

Única tabela

package br.com.efacilsistemas.ecampeonato.modelo;

import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import org.hibernate.annotations.Entity;

@Entity
public class Equipe implements Serializable {
	@Id
	@GeneratedValue
	private Long id;
	private  String nome;
	private String logo;
	
        ... Getts and Setts
}

Classe que Gera as tabelas

package br.com.efacilsistemas.ecampeonato.util;

import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
import br.com.efacilsistemas.ecampeonato.modelo.*;

public class GeraBanco {
	public static void main(String[] args) {
		AnnotationConfiguration conf = new AnnotationConfiguration();
		conf.configure();
		conf.addAnnotatedClass( Equipe.class );
        new SchemaExport(conf).create(true, true);
	}
}

Arquivo de configuração do Hibernate

<?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">com.mysql.jdbc.Driver</property>
        <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
        <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/ecampeonato</property>
        <property name="hibernate.connection.password">root</property>
        <property name="hibernate.connection.username">root</property>
		<property name="hibernate.show_sql">true</property>
		<property name="hibernate.hbm2ddl.auto">true</property>
		
		<mapping class="br.com.efacilsistemas.ecampeonato.modelo.Equipe"/>
    </session-factory>
</hibernate-configuration>

1 Resposta

ibotirama

Resolvido foi só mudar o import de Equipe de :

import org.hibernate.annotations.Entity;

para :

javax.persistence.Entity;

Valeu pessoal.

Criado 7 de janeiro de 2010
Ultima resposta 7 de jan. de 2010
Respostas 1
Participantes 1