"AnnotationException: mappedBy reference an unknown target entity property" in Hibernate

Solution Verified - Updated -

Issue

  • The exception below is raised while deploying a persistence unit:

    ... org.hibernate.AnnotationException: mappedBy reference an unknown target entity property: org.mypackage.ManySide.oneside in org.mypackage.OneSide.manySides
            at org.hibernate.cfg.annotations.CollectionBinder.bindStarToManySecondPass(CollectionBinder.java:708)
            at org.hibernate.cfg.annotations.CollectionBinder$1.secondPass(CollectionBinder.java:668)
            at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:66)
            at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1605)
            at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1363)
            at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1749)
            at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:94)
            at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:920)
            ...
    
  • The entity classes have been defined as follows

    @Entity
    public class OneSide {
        ...
        @OneToMany(mappedBy = "oneside" ...)
        private List<ManySide> manySides;
        ...
    }
    
    @Entity
    @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
    @DiscriminatorColumn(...)
    public abstract class Parent {
        ...
        @ManyToOne
        @JoinColumn(name = "COMMENT_ID")
        protected OneSide oneside;
        ...
    }
    
    @Entity
    public class ManySide extends Parent implements Serializable {
        ...
    }
    

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 5
    • 6
    • 7
  • Hibernate
    • 3
    • 4
    • 5

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.