A tabela de conta não é criada e aparece essa exceção e não sei o que pode estar errado.
package br.com.alura.jpa.teste;
import br.com.alura.jpa.modelo.Conta;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class CriaConta {
public static void main(String[] args) {
EntityManagerFactory emf = Persistence.createEntityManagerFactory("alura");
EntityManager em = emf.createEntityManager();
Conta c = new Conta();
c.setTitular("Fernanda");
c.setAgencia(3339);
c.setNumero(1234);
em.getTransaction().begin();
em.persist(c);
em.getTransaction().commit();
}
}
o persistence:
<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_2_0.xsd"
version="2.0">
<persistence-unit name= "alura">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<class>br.com.alura.jpa.modelo.Conta</class>
<properties>
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/alura_jpa" />
<property name="javax.persistence.jdbc.user" value="root" />
<property name="javax.persistence.jdbc.password" value="" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update" />
</properties>
</persistence-unit>
</persistence>
e a class Conta:
package br.com.alura.jpa.modelo;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Conta {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Basic(optional=false)
@Column(name="id",unique=true,nullable=false)
private Integer agencia;
private Integer numero;
private String titular;
private Long Id;
private Double saldo;
public Integer getAgencia() {
return agencia;
}
public void setAgencia(Integer agencia) {
this.agencia = agencia;
}
public Integer getNumero() {
return numero;
}
public void setNumero(Integer numero) {
this.numero = numero;
}
public String getTitular() {
return titular;
}
public void setTitular(String titular) {
this.titular = titular;
}
public Long getId() {
return Id;
}
public void setId(Long Id) {
this.Id = Id;
}
public Double getSaldo() {
return saldo;
}
public void setSaldo(Double saldo) {
this.saldo = saldo;
}
}