Hibernate - mappedBy引用未知的目标实体属性

时间:2016-06-10 13:12:23

标签: java hibernate

我正在使用Hibernate开发Java应用程序。 我的人际关系很困难。

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;

发生以下问题:

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)

核心属性存在于Pessoa类中。 为什么我收到这个错误?

0 个答案:

没有答案