org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass

Hibernate JIRA | Adam Warski | 9 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

    I have two dynamic model entites mapped as follows: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class entity-name="Superclass" discriminator-value="A"> <id name="id" type="integer"><generator class="native"/></id> <discriminator column="DISC" type="string" /> <property name="dataA" type="string"/> <subclass entity-name="Subclass" discriminator-value="B"> <property name="dataB" type="string"/> </subclass> </class> </hibernate-mapping> When I try to persist one of them (just invoking session.persist("Superclass", new HashMap()); is enough) I get the following exception: Exception in thread "main" org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3640) at org.jboss.envers.test.working.MyPersister.getSubclassEntityPersister(MyPersister.java:22) at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180) at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:70) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592) at org.jboss.envers.test.working.WorkingMain.main(WorkingMain.java:62)

    Hibernate JIRA | 9 years ago | Adam Warski
    org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass
  2. 0

    I have two dynamic model entites mapped as follows: <?xml version="1.0"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class entity-name="Superclass" discriminator-value="A"> <id name="id" type="integer"><generator class="native"/></id> <discriminator column="DISC" type="string" /> <property name="dataA" type="string"/> <subclass entity-name="Subclass" discriminator-value="B"> <property name="dataB" type="string"/> </subclass> </class> </hibernate-mapping> When I try to persist one of them (just invoking session.persist("Superclass", new HashMap()); is enough) I get the following exception: Exception in thread "main" org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3640) at org.jboss.envers.test.working.MyPersister.getSubclassEntityPersister(MyPersister.java:22) at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347) at org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180) at org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:70) at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38) at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618) at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592) at org.jboss.envers.test.working.WorkingMain.main(WorkingMain.java:62)

    Hibernate JIRA | 9 years ago | Adam Warski
    org.hibernate.HibernateException: instance not of expected entity type: java.util.HashMap is not a: Superclass
  3. 0

    HibernateException: Unable to resolve entity name from Class [java.lang.Boolean] expected instance/subclass of

    Stack Overflow | 2 years ago | CodeMed
    javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resolve entity name from Class [java.lang.Boolean] expected instance/subclass of [org.jvnet.hyperjaxb3.ejb.tests.pocustomized.II]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    debugging entitymanager while persisting complicated entity

    Stack Overflow | 2 years ago | CodeMed
    javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resolve entity name from Class [java.lang.Boolean] expected instance/subclass of [org.jvnet.hyperjaxb3.ejb.tests.pocustomized.II]
  6. 0

    Positional Parameter with IN clause in JPA

    Stack Overflow | 6 years ago | Steve
    javax.persistence.PersistenceException: org.hibernate.HibernateException: Unable to resolve entity name from Class [java.util.LinkedList] expected instance/subclass of [domain.CSMessage]

    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. org.hibernate.HibernateException

      instance not of expected entity type: java.util.HashMap is not a: Superclass

      at org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister()
    2. Hibernate
      AbstractEntityPersister.getSubclassEntityPersister
      1. org.hibernate.persister.entity.AbstractEntityPersister.getSubclassEntityPersister(AbstractEntityPersister.java:3640)
      1 frame
    3. org.jboss.envers
      MyPersister.getSubclassEntityPersister
      1. org.jboss.envers.test.working.MyPersister.getSubclassEntityPersister(MyPersister.java:22)
      1 frame
    4. Hibernate
      SessionImpl.getEntityPersister
      1. org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1347)
      1 frame
    5. Hibernate
      ForeignKeys.isTransient
      1. org.hibernate.engine.ForeignKeys.isTransient(ForeignKeys.java:180)
      1 frame
    6. Hibernate
      SessionImpl.persist
      1. org.hibernate.event.def.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:512)
      2. org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:70)
      3. org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:38)
      4. org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:618)
      5. org.hibernate.impl.SessionImpl.persist(SessionImpl.java:592)
      5 frames
    7. org.jboss.envers
      WorkingMain.main
      1. org.jboss.envers.test.working.WorkingMain.main(WorkingMain.java:62)
      1 frame