Dynamic entity model and inheritance - exception when trying to persist
-----------------------------------------------------------------------
Key: HHH-3351
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3351
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.6
Reporter: Adam Warski
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....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira