0

I'm developing an application in Java with Hibernate. I'm having trouble with relationships.

Class Nucleo

@Entity
@Table(name = "nucleo")
public class Nucleo {

    @Id
    @GeneratedValue
    @Column(name = "nuc_id")
    private Integer id;
    @Column(name = "nuc_nome")
    private String nome;
    @DateTimeFormat(pattern = "dd/MM/yyyy")
    @Column(name = "nuc_data_criacao")
    private Calendar dataCriacao;
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "nuc_id")
    private List<Telefone> telefone;
    @OneToMany(targetEntity = Pessoa.class, mappedBy="nucleo", fetch = FetchType.LAZY)
    private List<Pessoa> funcionarios;

Class Pessoa

@Entity
@Table(name = "pessoa")
public class Pessoa {

    @Id
    @GeneratedValue
    @Column(name = "pes_id")
    private Integer id;
    @Column(name = "pes_nome")
    private String nome;
    @Column(name = "pes_observacao")
    private String observacao;
    @ManyToOne
    @JoinTable(
        name = "trabalha",
        joinColumns = @JoinColumn(name = "pes_id"),
        inverseJoinColumns = @JoinColumn(name = "nuc_id")
    )
    private Nucleo nucleo;

It happens the following problem:

org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: br.edu.esaoabsp.sistemas.model.Pessoa.nucleo in br.edu.esaoabsp.sistemas.model.Nucleo.funcionarios
at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:769)
at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:729)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:70)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1697)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1426)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1846)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:857)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850)
at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.withTccl(ClassLoaderServiceImpl.java:425)

The nucleo attribute exists in the class Pessoa. Why I'm getting this error?

Adrian Shum
  • 38,812
  • 10
  • 83
  • 131

0 Answers0