Hibernate nao cria a tabela?

olá, estou tentando gerar uma tabela de acordo com a apostila do caelum utilizando o hibernate e o banco MySQL.

Porém ele nçao cria a tabela e eu não consigo identifica o erro… segue o erro

10:35:00,140  INFO Version:15 - Hibernate Annotations 3.2.1.GA
10:35:00,171  INFO Environment:509 - Hibernate 3.2.2
10:35:00,171  INFO Environment:527 - loaded properties from resource hibernate.properties: {hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.cache.provider_class=org.hibernate.cache.HashtableCacheProvider, hibernate.max_fetch_depth=1, hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect, hibernate.jdbc.use_streams_for_binary=true, hibernate.format_sql=true, hibernate.query.substitutions=yes 'Y', no 'N', hibernate.proxool.pool_alias=pool1, hibernate.connection.username=root, hibernate.cache.region_prefix=hibernate.test, hibernate.connection.url=jdbc:mysql://localhost/teste, hibernate.bytecode.use_reflection_optimizer=false, hibernate.connection.password=****, hibernate.jdbc.batch_versioned_data=true, hibernate.connection.pool_size=1}
10:35:00,171  INFO Environment:558 - using java.io streams to persist binary types
10:35:00,171  INFO Environment:676 - Bytecode provider name : cglib
10:35:00,203  INFO Environment:593 - using JDK 1.4 java.sql.Timestamp handling
10:35:00,375  INFO Dialect:152 - Using dialect: org.hibernate.dialect.MySQLMyISAMDialect
10:35:00,453 DEBUG AnnotationConfiguration:235 - Execute first pass mapping processing
10:35:00,546 DEBUG AnnotationConfiguration:435 - Process hbm files
10:35:00,546 DEBUG AnnotationConfiguration:443 - Process annotated classes
10:35:00,546 DEBUG AnnotationConfiguration:329 - processing manytoone fk mappings
10:35:00,562 DEBUG Configuration:1120 - processing extends queue
10:35:00,562 DEBUG Configuration:1124 - processing collection mappings
10:35:00,562 DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
10:35:00,562 DEBUG Configuration:1143 - processing association property references
10:35:00,562 DEBUG Configuration:1165 - processing foreign key constraints
10:35:00,562 DEBUG AnnotationConfiguration:235 - Execute first pass mapping processing
10:35:00,562 DEBUG AnnotationConfiguration:435 - Process hbm files
10:35:00,578 DEBUG AnnotationConfiguration:443 - Process annotated classes
10:35:00,578 DEBUG AnnotationConfiguration:329 - processing manytoone fk mappings
10:35:00,578 DEBUG Configuration:1120 - processing extends queue
10:35:00,578 DEBUG Configuration:1124 - processing collection mappings
10:35:00,578 DEBUG Configuration:1135 - processing native query and ResultSetMapping mappings
10:35:00,578 DEBUG Configuration:1143 - processing association property references
10:35:00,578 DEBUG Configuration:1165 - processing foreign key constraints
10:35:00,578  INFO SchemaExport:154 - Running hbm2ddl schema export
10:35:00,578 DEBUG SchemaExport:170 - import file not found: /import.sql
10:35:00,578  INFO SchemaExport:179 - exporting generated schema to database
10:35:00,593  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
10:35:00,593  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
10:35:00,593  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
10:35:00,593  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost/teste
10:35:00,593  INFO DriverManagerConnectionProvider:83 - connection properties: {user=root, password=root}
10:35:00,593 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
10:35:00,593 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
10:35:00,859 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:mysql://localhost/teste, Isolation Level: 4
10:35:00,859  INFO SchemaExport:196 - schema export complete
10:35:00,859 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
10:35:00,875  INFO DriverManagerConnectionProvider:147 - cleaning up connection pool: jdbc:mysql://localhost/teste
BUILD SUCCESSFUL (total time: 2 seconds)

e o código java…

package br.com.localhost.hibernate;

import javax.xml.validation.Schema;
import javax.xml.validation.Validator;
import javax.xml.validation.ValidatorHandler;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.criterion.Property;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class GeraTabelas {
    public static void main(String [] args){
        AnnotationConfiguration cfg = new AnnotationConfiguration();
        cfg.addAnnotatedClass(Produto.class);
        new SchemaExport(cfg).create(true,true);  
    }
}

Se alguém souber e puder me dar a dica agradeço…

[/]'s a todos…

Tb estou tendo o mesmo problema…nem no fórum do hibernate eu consigo uma luz.

Olá!
Tente usar:

		try{
			Configuration cfg = new AnnotationConfiguration()
			.addAnnotatedClass(Produto.class)
			.setProperty(Environment.HBM2DDL_AUTO, "create");
			;
			sessionFactory = cfg.buildSessionFactory();
		}
		catch(Exception e){
			e.printStackTrace();
		}

Estou passando pelos mesmos problemas que o nosso companheiro de post.
Tentei fazer o que o adriano falou. Mas não obtive sucesso!
Se alguém souber como fazer para criar as tabelas no banco utilizando o hibernate, ajuda a gente ai.

Tenho duas classes e o hibernate.properties em meu projeto.

Classe Produto:

import org.hibernate.*;
import org.hibernate.cfg.*;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;


@Entity
public class Produto {

    @Id @GeneratedValue
    private Long id;
    private String nome;
    private String descricao;
    private Double preco;

    //Respectivos getters e setters

Classe GeraTabelas

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

public class GeraTabelas {
    public static void main (String[] args) {

        AnnotationConfiguration cfg = new AnnotationConfiguration();
        cfg.addAnnotatedClass(Produto.class);
        new SchemaExport(cfg).create(true, true);

    }
}

O hibernate.properties está assim:

hibernate.dialect org.hibernate.dialect.MySQLDialect
hibernate.connection.driver_class com.mysql.jdbc.Driver
hibernate.connection.url jdbc:mysql://localhost:3306/superal
hibernate.connection.username root
hibernate.connection.password

Quando eu executo a classe GeraTabelas encontro o seguinte erro:

init:
deps-jar:
compile-single:
run-single:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
        at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
        at org.hibernate.cfg.annotations.Version.<clinit>(Version.java:12)
        at org.hibernate.cfg.AnnotationConfiguration.<clinit>(AnnotationConfiguration.java:78)
        at hibernatetravelpojo.GeraTabelas.main(GeraTabelas.java:10)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
        ... 4 more
Java Result: 1
CONSTRUÍDO COM SUCESSO (tempo total: 0 segundos)

Tô tentando há um tempão… e não tô obtendo sucesso.
arghh… :frowning:

Ae galera, consegui resolver o problema…
lá vai a [SOLUÇÃO]

No site: http://www.slf4j.org/codes.html#StaticLoggerBinder existe o seguinte comentário sobre a Exceção gerada (comentada no post anterior):
This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

Em resumo… Ele reclama que está faltando alguns arquivos JARs… baixei a APL logback-0.9.9 http://logback.qos.ch/download.html e adicionei os .JARs. E prontoooo… Funcionando corretamente!!!

Algumas pequenas alterações nas classes:

GeraTabelas

package hibernatetravelpojo;

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

public class GeraTabelas {

	private static void create(AnnotationConfiguration cfg) {
		new SchemaExport(cfg).create(true, true);		
	}

	public static void main(String[] args){		
		AnnotationConfiguration cfg = new AnnotationConfiguration();
		
		try{	
			create(cfg.addAnnotatedClass(Produto.class));
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}

Produto

package hibernatetravelpojo;

import java.io.Serializable;

import javax.persistence.Id;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;

import javax.persistence.Entity;


@Entity
@Table (name="PRODUTO")
public class Produto implements Serializable{

	private static final long serialVersionUID = 1L;
	
	@Id @GeneratedValue
	private Long id;
	
	private String nome;
	
	@Column(name="descricao",nullable=true,length=50)
	private String descricao;
	
	private Double preco;	

Bom é isso!!! Não desistam nunca!! :lol: