[hibernate-issues] [Hibernate-JIRA] Closed: (HHH-3351) Dynamic entity model and inheritance - exception when trying to persist

Steve Ebersole (JIRA) noreply at atlassian.com
Mon Oct 27 17:30:05 EDT 2008


     [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Steve Ebersole closed HHH-3351.
-------------------------------

         Assignee: Steve Ebersole
       Resolution: Fixed
    Fix Version/s: 3.4
                   3.3.x

> Dynamic entity model and inheritance - exception when trying to persist
> -----------------------------------------------------------------------
>
>                 Key: HHH-3351
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
>             Project: Hibernate Core
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.2.6
>            Reporter: Adam Warski
>            Assignee: Steve Ebersole
>             Fix For: 3.3.x, 3.4
>
>
> 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)

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list