[RESOLVIDO] - Gerar tabelas a partir de Beans

Boa tarde a todos.

Sei que tem muitos outros tópicos parecidos, mas nenhuma solução resolveu meu problema.

Nunca fiz isso, entaoa gora to querendo criar as tabelas do bando (MySQL) a partir dos Beans, mas não estou tento sucesso. Estou usando a apostila da K19 -JPA e Hibernate.

package com.livraria.entidades;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity(name="editora")
public class Editora {
	@Id
	@GeneratedValue
	private Long id;
	private String nome;
	private String email;
	private String data;

	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getNome() {
		return nome;
	}
	public void setNome(String nome) {
		this.nome = nome;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public void setData(String data) {
		this.data = data;
	}
	public String getData() {
		return data;
	}
}
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns = "http://java.sun.com/xml/ns/persistence"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
 	version="1.0">

	<persistence-unit name="livraria" transaction-type="RESOURCE_LOCAL">

		<provider>org.hibernate.ejb.HibernatePersistence</provider>
		<properties>
			<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLInnoDBDialect"/>
			<property name="hibernate.hbm2ddl.auto" value="update"/>
			<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
			<property name="javax.persistence.jdbc.user" value="root"/>
			<property name="javax.persistence.jdbc.password" value="root"/>
			<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/livraria"/>
			<property name="hibernate.show_sql" value="true"/>
            <property name="hibernate.format_sql" value="true"/>
		</properties>
	</persistence-unit>
</persistence>
package com.livraria.entidades;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

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

		EntityManagerFactory factory = Persistence.createEntityManagerFactory("livraria");

//		EntityManager manager = factory.createEntityManager();
//		manager.getTransaction().begin();
//
//		Editora editora = new Editora();
//		editora.setEmail("email@email.com");
//		editora.setNome("Nome Editora");
//		editora.setData(new SimpleDateFormat("dd/MM/yyyy").format(new Date()));
//
//		manager.persist(editora);
//
//		manager.getTransaction().commit();

		factory.close();
	}
}
Ago 20, 2012 4:01:45 PM org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final}
Ago 20, 2012 4:01:45 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.1.6.Final}
Ago 20, 2012 4:01:45 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Ago 20, 2012 4:01:45 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Ago 20, 2012 4:01:45 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
Ago 20, 2012 4:01:45 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
Ago 20, 2012 4:01:45 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: true
Ago 20, 2012 4:01:45 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/livraria]
Ago 20, 2012 4:01:45 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****, autocommit=true, release_mode=auto}
Ago 20, 2012 4:01:46 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
Ago 20, 2012 4:01:46 PM org.hibernate.engine.transaction.internal.TransactionFactoryInitiator initiateService
INFO: HHH000268: Transaction strategy: org.hibernate.engine.transaction.internal.jdbc.JdbcTransactionFactory
Ago 20, 2012 4:01:46 PM org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory <init>
INFO: HHH000397: Using ASTQueryTranslatorFactory
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000228: Running hbm2ddl schema update
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000102: Fetching database metadata
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000396: Updating schema
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: editora
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.DatabaseMetadata getTableMetadata
INFO: HHH000262: Table not found: editora
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: HHH000388: Unsuccessful: create table editora (id bigint not null auto_increment, data varchar(255), email varchar(255), nome varchar(255), primary key (id)) type=InnoDB
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 7
Ago 20, 2012 4:01:46 PM org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
Ago 20, 2012 4:01:46 PM org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH000030: Cleaning up connection pool [jdbc:mysql://localhost:3306/livraria]

Se eu crio a tabela direto no banco, consigo incluir registros sem problemas (somente dentro da transação).

Mas por que a tabela não é criada?

Obrigado qualquer ajuda.

Galera, acabo de perceber o problema. O dialeto que a apostila espeficica por alguma razão nao funciona. O erro está exatamente onde o log aponta. Não é a primeira vez que tenho esse problema com apostilas :C

Procurei na net outro dialect pro MySQL e funcionou!

Estava usando: org.hibernate.dialect.MySQLInnoDBDialect
Troquei por: org.hibernate.dialect.MySQLDialect