Solucionado (ver solução)
Solucionado
(ver solução)
3
respostas

Exception in thread "main" java.lang.ExceptionInInitializerError Podem me ajudar?

Dec 01, 2018 5:42:10 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation INFO: HHH000204: Processing PersistenceUnitInfo [ name: financas ...] Dec 01, 2018 5:42:10 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {5.3.7.Final} Dec 01, 2018 5:42:10 PM org.hibernate.cfg.Environment INFO: HHH000206: hibernate.properties not found Dec 01, 2018 5:42:10 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager INFO: HCANN000001: Hibernate Commons Annotations {5.0.4.Final} Dec 01, 2018 5:42:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!) Dec 01, 2018 5:42:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost/financas?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC] Dec 01, 2018 5:42:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001001: Connection properties: {user=root} Dec 01, 2018 5:42:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator INFO: HHH10001003: Autocommit mode: false Dec 01, 2018 5:42:10 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections INFO: HHH000115: Hibernate connection pool size: 20 (min=1) Dec 01, 2018 5:42:11 PM org.hibernate.dialect.Dialect INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect Exception in thread "main" java.lang.ExceptionInInitializerError at br.com.caelum.financas.Teste.TesteBuscaConta.main(TesteBuscaConta.java:12) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: financas] Unable to build Hibernate SessionFactory at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.persistenceException(EntityManagerFactoryBuilderImpl.java:1016) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:942) at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:56) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:79) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:54) at br.com.caelum.financas.Util.JPAUtil.(JPAUtil.java:9) ... 1 more Caused by: org.hibernate.MappingException: Could not determine type for: br.com.caelum.financas.modelo.Conta, at table: Movimentacao, for columns: [org.hibernate.mapping.Column(conta)] at org.hibernate.mapping.SimpleValue.getType(SimpleValue.java:486) at org.hibernate.mapping.SimpleValue.isValid(SimpleValue.java:453) at org.hibernate.mapping.Property.isValid(Property.java:226) at org.hibernate.mapping.PersistentClass.validate(PersistentClass.java:624) at org.hibernate.mapping.RootClass.validate(RootClass.java:267) at org.hibernate.boot.internal.MetadataImpl.validate(MetadataImpl.java:347) at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:466) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:939) ... 5 more

3 respostas

Esqueci de mandar

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

    Conta conta = new Conta();
    conta.setTitular("Rubens");
    conta.setAgencia("0102");
    conta.setNumero("135");
    conta.setBanco("Banco do Brasil");

    Movimentacao movimentacao = new Movimentacao();
    movimentacao.setData(Calendar.getInstance());
    movimentacao.setDescricao("Churrascaria");
    movimentacao.setTipo(TipoMovimentacao.SAIDA);
    movimentacao.setValor(new BigDecimal("200.0"));

    movimentacao.setConta(conta);


    EntityManager em = new JPAUtil().getEntityManager();
    em.getTransaction().begin();

    em.persist(conta);
    em.persist(movimentacao);

    em.getTransaction().commit();
    em.close();
}

}

Não sei o motivo

solução!

Resolvido