estou tentando persistem no JPA e Hibernate mais esotu com erro.
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.engine.spi.SessionFactoryImplementor.getProperties()Ljava/util/Properties;
at org.hibernate.jpa.internal.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:124)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:890)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at aprendendo.ClasseTeste.main(ClasseTeste.java:17)
package aprendendo;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import model.Cliente;
public class ClasseTeste {
public static void main(String[] args) {
Cliente cliente = new Cliente();
cliente.setNome("teste");
cliente.setTelefone_celular("88 8888-8855");
EntityManagerFactory factory = Persistence.createEntityManagerFactory("oficina");
EntityManager manager = factory.createEntityManager();
manager.getTransaction().begin();
manager.persist(cliente);
manager.getTransaction().commit();
manager.close();
}
}
package model;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class Cliente implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String nome;
private String cpf;
private String telefone_fixo;
private String telefone_celular;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getTelefone_fixo() {
return telefone_fixo;
}
public void setTelefone_fixo(String telefone_fixo) {
this.telefone_fixo = telefone_fixo;
}
public String getTelefone_celular() {
return telefone_celular;
}
public void setTelefone_celular(String telefone_celular) {
this.telefone_celular = telefone_celular;
}
/* public List getServicos() {
return servicos;
}
public void setServicos(List<Servico> servicos) {
this.servicos = servicos;
}
*/
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
}
<?xml version="1.0" encoding="UTF-8"?> <!-- nome da persitência -->
<persistence-unit name="oficina" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>model.Cliente</class>
<!-- propriedade de conexão do banco -->
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/oficina" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="root" />
<!-- Propriedade do Hibernate. | update | create | create-drop -->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>