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

Pessoal,

Estou com o mesmo problema, mas não estou conseguindo resolver!

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?

provavelmente sua(s) classe(s) nao esta(ao) no arquivo de conf

Eu tive este mesmo problema.

O que estava faltando era mapear a classe no hibernate.cfg.xml

Valeu!

Resolvido