AnnotationException: Use of @OneToMany or @ManyToMany target

AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class

Pessoal,

Estou com este problema, mas não estou conseguindo resolver:
AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class

Classe Empresa

@Entity
@Table(name = "empresa")
public class Empresa implements java.io.Serializable {
    @Id
    @SequenceGenerator(name = "ID_Empresa")
    @Column(name = "ID_Empresa")
    private int id;
    
    @Column(name = "Nome")
    private String nome;
    
    @OneToMany(mappedBy = "empresa", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private Collection<Setor> setores;[/code]

Classe Setor
[code]@Entity
@Table(name = "setor")
public class Setor implements java.io.Serializable {
    @Id
    @SequenceGenerator(name = "ID_Setor")
    @Column(name = "ID_Setor")
    private int id;
    
    @Column(name = "Nome")
    private String nome;
    
    @ManyToOne 
    @JoinColumn(name = "ID_Empresa", nullable = false, updatable = true)
    private Empresa empresa;[/code]

Erro:
[code]Exception in thread "main" java.lang.ExceptionInInitializerError
        at br.com.quality.util.HibernateUtil.<clinit>(HibernateUtil.java:32)
        at br.com.quality.dominio.teste.HibernateTeste.main(HibernateTeste.java:33)
Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: br.com.quality.dominio.Empresa.setores[br.com.quality.dominio.Setor]
        at org.hibernate.cfg.annotations.CollectionBinder.bindManyToManySecondPass(CollectionBinder.java:979)
        at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:530)
        at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:471)
        at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:43)
        at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1130)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:296)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1286)
        at br.com.quality.util.HibernateUtil.<clinit>(HibernateUtil.java:26)
        ... 1 more

O que pode está acontecendo?

opa,

você já mapeou esta classe no hibernate config?

:joia:

Marcos,

Realmente foi um erro grosseiro em não ter mapeado a classe no hibernate config.

Bati tanta cabeça para saber como mapear a classe Setor usando Annotation do JPA que esqueci de um detalhe primordial.

Obrigado por responder ao meu post.

[quote=“marcossousa”]opa,

você já mapeou esta classe no hibernate config?

:joia:[/quote]