javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz

Hibernate JIRA | Markus Junginger | 1 decade ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. The class Xyz is a super class for a couple of entity classes: @MappedSuperclass public abstract class Xyz{...} The following association to Xyz does not work (see exception below) @ManyToOne(fetch = FetchType.LAZY) @JoinColumns({...}) private Xyz test; If it matters, each entity (the sub classes of Xyz) is annotated with @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). Here's the execption: javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) ... Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) ... 20 more

    Hibernate JIRA | 1 decade ago | Markus Junginger
    javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz
  2. 0

    I think it should be possible to have polymorphic association to a class annotated as a MappedSuperclass. However, this combination throws an exception. The class Xyz is a super class for a couple of entity classes: @MappedSuperclass public abstract class Xyz{...} The following association to Xyz does not work (see exception below) @ManyToOne(fetch = FetchType.LAZY) @JoinColumns({...}) private Xyz test; If it matters, each entity (the sub classes of Xyz) is annotated with @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS). Here's the execption: javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196) at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37) at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27) ... Caused by: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz at org.hibernate.cfg.FkSecondPass.doSecondPass(FkSecondPass.java:40) at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:261) at org.hibernate.cfg.Configuration.buildMappings(Configuration.java:1034) at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configuration.java:868) at org.hibernate.ejb.EventListenerConfigurator.configure(EventListenerConfigurator.java:163) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:641) at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:134) at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:188) ... 20 more

    Hibernate JIRA | 1 decade ago | Markus Junginger
    javax.persistence.PersistenceException: org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz
  3. 0

    Play2.11 Play can not find the model class but I can run pure JPA Junit test properly, Please come to help, thanks

    Stack Overflow | 4 years ago | LWang
    javax.persistence.PersistenceException: [PersistenceUnit: DEVUnit] class or package not found
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Java JPA Hibernate Connection Issue

    Stack Overflow | 3 years ago
    javax.persistence.PersistenceException: Unable to configure EntityManagerFactory
  6. 0

    About using MySQL Database

    GitHub | 4 years ago | romaar
    javax.persistence.PersistenceException: [PersistenceUnit: release] Unable to build EntityManagerFactory

    4 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. javax.persistence.PersistenceException

      org.hibernate.AnnotationException: @OneToOne or @ManyToOne on play.abc.test references an unknown entity: play.Xyz

      at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory()
    2. Hibernate EJB
      HibernatePersistence.createEntityManagerFactory
      1. org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:196)
      2. org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
      2 frames
    3. JavaEE 7
      Persistence.createEntityManagerFactory
      1. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
      2. javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
      2 frames