3
respostas

Não consigo ter acesso a tabela movimentação

nao to tendo acesso a criação do item movimentação da aula JPA: run: jul 29, 2017 8:36:19 PM org.hibernate.annotations.common.Version INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} jul 29, 2017 8:36:19 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.1.9.Final} jul 29, 2017 8:36:19 PM org.hibernate.cfg.Environment INFO: HHH000206: hibernate.properties not found jul 29, 2017 8:36:19 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist Exception in thread "main" java.lang.ExceptionInInitializerError at br.com.caelum.financas.teste.TesteConta.main(TesteConta.java:29) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: financas] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at br.com.caelum.financas.util.JPAUtil.(JPAUtil.java:9) ... 1 more Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: br.com.caelum.financas.modelo.Cliente.conta, referenced property unknown: br.com.caelum.financas.modelo.Conta.cliente at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:158) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1597) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ... 6 more C:\Users\Luciano\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)

3 respostas

Opa, faltou você colocar a annotation do ManyToOne em cima do atributo conta, na classe Movimentacao.

OI Alberto Muito obrigado pela ajuda, eu coloquei esse codigo la mas iand ada erro: package br.com.caelum.financas.modelo;

import java.math.BigDecimal; import java.util.Calendar; import java.util.List;

import javax.persistence.*;

@Entity public class Movimentacao {

@Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id;

private BigDecimal valor;

@Enumerated(EnumType.STRING) private TipoMovimentacao tipoMovimentacao;

@Temporal(TemporalType.DATE) private Calendar data;

private String descricao;

@ManyToOne private Conta conta;

@ManyToMany private List categorias;

public Integer getId() { return id; }

public List getCategorias() { return categorias; }

public void setCategorias(List categorias) { this.categorias = categorias; }

public void setId(Integer id) { this.id = id; }

public BigDecimal getValor() { return valor; }

public void setValor(BigDecimal valor) { this.valor = valor; }

public TipoMovimentacao getTipoMovimentacao() { return tipoMovimentacao; }

public void setTipoMovimentacao(TipoMovimentacao tipoMovimentacao) { this.tipoMovimentacao = tipoMovimentacao; }

public Calendar getData() { return data; }

public void setData(Calendar data) { this.data = data; }

public String getDescricao() { return descricao; }

public void setDescricao(String descricao) { this.descricao = descricao; }

public Conta getConta() { return conta; }

public void setConta(Conta conta) { this.conta = conta; }

} ( Quinto capitulo aula de Hibernate) o erro ao executar esse teste é : run: jul 30, 2017 7:30:11 PM org.hibernate.annotations.common.Version INFO: HCANN000001: Hibernate Commons Annotations {4.0.1.Final} jul 30, 2017 7:30:11 PM org.hibernate.Version logVersion INFO: HHH000412: Hibernate Core {4.1.9.Final} jul 30, 2017 7:30:11 PM org.hibernate.cfg.Environment INFO: HHH000206: hibernate.properties not found jul 30, 2017 7:30:11 PM org.hibernate.cfg.Environment buildBytecodeProvider INFO: HHH000021: Bytecode provider name : javassist Exception in thread "main" java.lang.ExceptionInInitializerError at br.com.caelum.financas.teste.TesteConta.main(TesteConta.java:29) Caused by: javax.persistence.PersistenceException: [PersistenceUnit: financas] Unable to build EntityManagerFactory at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:915) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:890) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:57) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:63) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:47) at br.com.caelum.financas.util.JPAUtil.(JPAUtil.java:9) ... 1 more Caused by: org.hibernate.AnnotationException: Unknown mappedBy in: br.com.caelum.financas.modelo.Cliente.conta, referenced property unknown: br.com.caelum.financas.modelo.Conta.cliente at org.hibernate.cfg.OneToOneSecondPass.doSecondPass(OneToOneSecondPass.java:158) at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1597) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1355) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1737) at org.hibernate.ejb.EntityManagerFactoryImpl.(EntityManagerFactoryImpl.java:94) at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:905) ... 6 more C:\Users\Luciano\AppData\Local\NetBeans\Cache\8.2\executor-snippets\run.xml:53: Java returned: 1 FALHA NA CONSTRUÇÃO (tempo total: 0 segundos)

Consegui resolver ! Baixei o codigo fonte apresentando no final do capitulo q percebi que havia duas notations minhas que por algum motivo não estavam sendo utilizadas. Muito Obrigado Pela ajuda.