Olá galera, eu uma classe p/ gerar tabelas p/ mim.
Ocorre que, quando executo a classe, aparece uma menssagem no console dizendo que tem um erro na minha SQL syntax.
Bom, vamos ao Erro gerado no console
[code]14:53:07 INFO [Version ] Hibernate Annotations 3.4.0.GA
14:53:07 INFO [Environment ] Hibernate 3.3.2.GA
14:53:07 INFO [Environment ] hibernate.properties not found
14:53:07 INFO [Environment ] Bytecode provider name : javassist
14:53:07 INFO [Environment ] using JDK 1.4 java.sql.Timestamp handling
14:53:07 INFO [Version ] Hibernate Commons Annotations 3.1.0.GA
14:53:07 INFO [Configuration ] configuring from resource: /hibernate.cfg.xml
14:53:07 INFO [Configuration ] Configuration resource: /hibernate.cfg.xml
14:53:08 INFO [Configuration ] Configured SessionFactory: null
14:53:08 INFO [Dialect ] Using dialect: org.hibernate.dialect.MySQLInnoDBDialect
14:53:08 INFO [AnnotationBinder ] Binding entity from annotated class: br.com.perfaco.classes.Cliente
14:53:08 INFO [EntityBinder ] Bind entity br.com.perfaco.classes.Cliente on table Cliente
14:53:08 INFO [AnnotationConfiguration] Hibernate Validator not found: ignoring
14:53:08 INFO [SchemaExport ] Running hbm2ddl schema export
14:53:08 INFO [SchemaExport ] exporting generated schema to database
14:53:08 INFO [DriverManagerConnectionProvider] Using Hibernate built-in connection pool (not for production use!)
14:53:08 INFO [DriverManagerConnectionProvider] Hibernate connection pool size: 20
14:53:08 INFO [DriverManagerConnectionProvider] autocommit mode: false
14:53:08 INFO [DriverManagerConnectionProvider] using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/perfaco
14:53:08 INFO [DriverManagerConnectionProvider] connection properties: {user=root, password=****}
drop table if exists Cliente
create table Cliente (
id bigint not null auto_increment,
endereco varchar(255),
nome varchar(255),
telefone varchar(255),
primary key (id)
) type=InnoDB
14:53:08 ERROR [SchemaExport ] Unsuccessful: create table Cliente (id bigint not null auto_increment, endereco varchar(255), nome varchar(255), telefone varchar(255), primary key (id)) type=InnoDB
14:53:08 ERROR [SchemaExport ] 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 1
14:53:08 INFO [SchemaExport ] schema export complete
14:53:08 INFO [DriverManagerConnectionProvider] cleaning up connection pool: jdbc:mysql://localhost:3306/perfaco
[/code]
Como podem ver, nao é nem um erro, ele simplesmente da uma menssagem de Unsuccessful, e nao cria a minha tabela.
A classe que gera a tabela é a seguinte:
[code]package br.com.perfaco.classes;
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.configure();
SchemaExport se = new SchemaExport(cfg);
se.create(true, true);
}
}
[/code]
E a minha “tabela” é a seguinte:
[code]package br.com.perfaco.classes;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Cliente {
@Id
@GeneratedValue
private Long id;
String nome, telefone, endereco;
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 getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
}
[/code]
E meu arquivo hibernate.cfg
[code]<?xml version='1.0' encoding='utf-8'?>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/perfaco</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">root</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.format_sql">true</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
<mapping class="br.com.perfaco.classes.Cliente"/>
</session-factory>
[/code]
Gostaria que a galera do guj me desse + uma força ai
Obrigado a todos