'Hibernate Annotation Exception: "Use of @OneToMany or @ManyToMany targeting an unmapped class"

I keep getting a "Use of @OneToMany or @ManyToMany targeting an unmapped class" exception. I've read every related entry about this exception but still don't know where the root of problem is. Does anyone has an idea what the solution might be? Thanks for your time.

Parent class

import javax.persistence.Entity;

@Entity
@Table (name = "PARENT")
public class Parent extends BaseParent implements Serializable 
{
    private static final long serialVersionUID = -4602934192967499108L;

    @Column (name = "PHONE")
    private String phone; 

    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    private List<Child> children;
        
    public Parent()
    {
    }
 
    public Parent(String name,String phone)
    {
      super(name);
      this.phone= phone;
    }

    public List<Children> getChildren() 
    {
        return children;
    }
    
    public void setChildren(List<Children> children) 
    {
        this.children= children;
    }   
    @Override
    public Type getType()
    {
        return Type.PARENT;
    }
     public String getPhone() 
    {
        return phone;
    }

    public void setPhone(String phone)
    {
        this.phone= phone;
    }
}

BaseParent Class

..
import javax.persistence.MappedSuperclass;
import javax.xml.bind.annotation.XmlRootElement;
import javax.persistence.Transient;

@XmlRootElement
@MappedSuperclass
public abstract class BaseParent implements Serializable, Comparable<BaseParent>
{   
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", nullable = false)
    protected long id;

    @Column(name = "ADDRESS")
    protected String address;

    @Column(name = "ACTIVE")
    protected boolean active;

    @Transient
    protected Type type;

    public BaseParent(String address, boolean active)
    {
        this.address= address;
        this.active = active;
    }

    public boolean isActive()
    {
        return active;
    }

    public void setActive(boolean active)
    {
        this.active = active;
    }
    public String getAddress()
    {
        return address;
    }
    public void setAddress(String address)
    {
        this.address= address;
    }
    public Type getType()
    {
        return type;
    }

    @Override
    public int compareTo(BaseParent other)
    {       
        int addressCompareResult = 
        this.address.toLowerCase().compareTo(other.address.toLowerCase());

        return addressCompareResult ;              
    }    
 
    @Override
    public boolean equals(Object other)
    {
        return other instanceof BaseParent && this.id == ((BaseParent) other).id;
    }

    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 23 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    } 

Child class

..
import javax.persistence.Entity;

@Entity
@Table (name = "CHILD")
public class Child implements Serializable
{
    private static final long serialVersionUID = 2198423097171379808L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "ID", nullable = false)
    private long id;

    @Column (name = "DATE_OF_BIRTH")
    private String dateOfBirth;

    @ManyToOne
    @JoinColumn(name = "PARENT_ID")
    private Parent parent;  

    public long getId() 
    {
        return id;
    }

    public String getDateOfBirth() 
    {
        return dateOfBirth;
    }

    public void setDateOfBirth(String dateOfBirth) 
    {
        this.dateOfBirth= dateOfBirth;
    }

    public Parent getParent() 
    {
        return Parent;
    }

    public void setParent(Parent parent) 
    {
        this.parent = parent;
    }
}

persistence.xml

  <persistence-unit name="myPersistenceUnit">
    <class>de.company.model.entities.Parent</class>
    <class>de.company.model.entities.Child</class>
     ...
    <exclude-unlisted-classes>true</exclude-unlisted-classes>
 </persistence-unit>

error log

ERROR [org.jboss.as.controller.management-operation] (Controller Boot Thread) WFLYCTL0013: Operation ("deploy") failed - address: ([("deployment" => "web.primefacesproject.faces-3.18.7-SNAPSHOT.war")]) - 
failure description: {"WFLYCTL0080: Failed services" => {"jboss.persistenceunit.\"web.primefacesproject.faces-3.18.7-SNAPSHOT.war#thePersistence\"" => "org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: de.company.model.entities.Parent.children[de.company.model.entities.child]
    Caused by: org.hibernate.AnnotationException: Use of @OneToMany or @ManyToMany targeting an unmapped class: de.company.model.entities.Parent.children[de.company.model.entities.child]"}, "WFLYCTL0288: One or more services were unable to start due to one or more indirect dependencies not being available." => { "Services that were unable to start:" => ["jboss.deployment.unit.\"web.primefacesproject.faces-3.18.7-SNAPSHOT.war\".WeldStartService"], "Services that may be the cause:" => [
"jboss.clustering.web.route.default-server"



Solution 1:[1]

Could you add the exception log it's help to find the root cause of problem.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Chinnappa Raj J