org.hibernate.MappingException: Unknown entity: null

Hibernate JIRA | Gunnar Morling | 2 years 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

    When having the following hierarchy: {code} @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) class CommunityMember { ... } {code} {code} @Entity class Employee extends CommunityMember { ... } {code} and running this query: {code} em.createQuery( "from Employee e" ).getResultList(); {code} then an exception is raised: {code} org.hibernate.MappingException: Unknown entity: null at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1379) at org.hibernate.ogm.loader.impl.OgmLoader.instanceNotYetLoaded(OgmLoader.java:951) at org.hibernate.ogm.loader.impl.OgmLoader.getRow(OgmLoader.java:854) at org.hibernate.ogm.loader.impl.OgmLoader.getRowFromResultSet(OgmLoader.java:427) at org.hibernate.ogm.loader.impl.OgmLoader.doQuery(OgmLoader.java:338) at org.hibernate.ogm.loader.impl.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:267) at org.hibernate.ogm.loader.impl.OgmLoader.loadEntity(OgmLoader.java:186) at org.hibernate.ogm.loader.impl.OgmLoader.loadEntities(OgmLoader.java:204) at org.hibernate.ogm.query.impl.OgmQueryLoader.entity(OgmQueryLoader.java:124) at org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:91) at org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497) at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:127) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) {code} I guess that's a bug in engine that needs to be fixed. But even then we still need to append the DTYPE to WHERE clauses generated for MongoDB/Neo4j to restrict on the right sub-type. I don't think that's the case atm.

    Hibernate JIRA | 2 years ago | Gunnar Morling
    org.hibernate.MappingException: Unknown entity: null
  2. 0

    When having the following hierarchy: {code} @Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) class CommunityMember { ... } {code} {code} @Entity class Employee extends CommunityMember { ... } {code} and running this query: {code} em.createQuery( "from Employee e" ).getResultList(); {code} then an exception is raised: {code} org.hibernate.MappingException: Unknown entity: null at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096) at org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1379) at org.hibernate.ogm.loader.impl.OgmLoader.instanceNotYetLoaded(OgmLoader.java:951) at org.hibernate.ogm.loader.impl.OgmLoader.getRow(OgmLoader.java:854) at org.hibernate.ogm.loader.impl.OgmLoader.getRowFromResultSet(OgmLoader.java:427) at org.hibernate.ogm.loader.impl.OgmLoader.doQuery(OgmLoader.java:338) at org.hibernate.ogm.loader.impl.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:267) at org.hibernate.ogm.loader.impl.OgmLoader.loadEntity(OgmLoader.java:186) at org.hibernate.ogm.loader.impl.OgmLoader.loadEntities(OgmLoader.java:204) at org.hibernate.ogm.query.impl.OgmQueryLoader.entity(OgmQueryLoader.java:124) at org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:91) at org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76) at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497) at org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:127) at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236) at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264) at org.hibernate.internal.QueryImpl.list(QueryImpl.java:103) at org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573) at org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449) {code} I guess that's a bug in engine that needs to be fixed. But even then we still need to append the DTYPE to WHERE clauses generated for MongoDB/Neo4j to restrict on the right sub-type. I don't think that's the case atm.

    Hibernate JIRA | 2 years ago | Gunnar Morling
    org.hibernate.MappingException: Unknown entity: null

    Root Cause Analysis

    1. org.hibernate.MappingException

      Unknown entity: null

      at org.hibernate.internal.SessionFactoryImpl.getEntityPersister()
    2. Hibernate
      SessionImpl.instantiate
      1. org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
      2. org.hibernate.internal.SessionImpl.instantiate(SessionImpl.java:1379)
      2 frames
    3. Hibernate Object Grid Mapper
      OgmQueryLoader.list
      1. org.hibernate.ogm.loader.impl.OgmLoader.instanceNotYetLoaded(OgmLoader.java:951)
      2. org.hibernate.ogm.loader.impl.OgmLoader.getRow(OgmLoader.java:854)
      3. org.hibernate.ogm.loader.impl.OgmLoader.getRowFromResultSet(OgmLoader.java:427)
      4. org.hibernate.ogm.loader.impl.OgmLoader.doQuery(OgmLoader.java:338)
      5. org.hibernate.ogm.loader.impl.OgmLoader.doQueryAndInitializeNonLazyCollections(OgmLoader.java:267)
      6. org.hibernate.ogm.loader.impl.OgmLoader.loadEntity(OgmLoader.java:186)
      7. org.hibernate.ogm.loader.impl.OgmLoader.loadEntities(OgmLoader.java:204)
      8. org.hibernate.ogm.query.impl.OgmQueryLoader.entity(OgmQueryLoader.java:124)
      9. org.hibernate.ogm.query.impl.OgmQueryLoader.listOfEntities(OgmQueryLoader.java:91)
      10. org.hibernate.ogm.query.impl.OgmQueryLoader.list(OgmQueryLoader.java:76)
      10 frames
    4. Hibernate
      QueryLoader.list
      1. org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:497)
      1 frame
    5. Hibernate Object Grid Mapper
      OgmQueryTranslator.list
      1. org.hibernate.ogm.query.impl.OgmQueryTranslator.list(OgmQueryTranslator.java:127)
      1 frame
    6. Hibernate
      QueryImpl.list
      1. org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:236)
      2. org.hibernate.internal.SessionImpl.list(SessionImpl.java:1264)
      3. org.hibernate.internal.QueryImpl.list(QueryImpl.java:103)
      3 frames
    7. org.hibernate.jpa
      QueryImpl.getResultList
      1. org.hibernate.jpa.internal.QueryImpl.list(QueryImpl.java:573)
      2. org.hibernate.jpa.internal.QueryImpl.getResultList(QueryImpl.java:449)
      2 frames