Bom dia,
venho aki mais uma vez para postar uma dúvida sobre hibernate.
Estou estudando pela apostila da Caelum da loja virtual e bem no inicio é criado um banco de dados para uma classe Usuario, segue o código:
[code]package br.com.caelum.lojavirtual.modelo;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Usuario {
@Id
@GeneratedValue
private Long id;
private String login;
private String senha;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
}[/code]
hibernate.cfg.xml:
[code]<?xml version="1.0" encoding="UTF-8"?>
com.mysql.jdbc.Driver jdbc:mysql://localhost/teste root org.hibernate.dialect.MySQLDialect true true [/code]e a classe que gera o banco:
[code]package br.com.caelum.lojavirtual.util;
import org.hibernate.HibernateException;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class GeraBanco {
public static void main(String[] args) throws HibernateException{
try{
/Configuration conf = new Configuration().configure(“hibernate.cfg.xml”);
SchemaExport se = new SchemaExport(conf);
se.create(true, true);/
Configuration conf = new AnnotationConfiguration();
conf.configure();
SchemaExport se = new SchemaExport(conf);
se.create(true, true);
}catch(Exception e){
e.printStackTrace();
}
}
}[/code]
e finalmente o erro:
10:38:07,203 INFO Version:15 - Hibernate Annotations 3.3.0.GA
10:38:07,218 INFO Environment:464 - Hibernate 3.0.2
10:38:07,218 INFO Environment:477 - hibernate.properties not found
10:38:07,218 INFO Environment:510 - using CGLIB reflection optimizer
10:38:07,218 INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
10:38:07,296 INFO Configuration:1160 - configuring from resource: /hibernate.cfg.xml
10:38:07,296 INFO Configuration:1131 - Configuration resource: /hibernate.cfg.xml
10:38:07,531 INFO Configuration:1272 - Configured SessionFactory: null
10:38:07,562 INFO Dialect:92 - Using dialect: org.hibernate.dialect.MySQLDialect
Exception in thread "main" java.lang.NoSuchFieldError: sqlResultSetMappings
at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings(AnnotationConfiguration.java:175)
at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:263)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:588)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:64)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:49)
at br.com.caelum.lojavirtual.util.GeraBanco.main(GeraBanco.java:17)
alguem poderia me socorrer??
obrigado