Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] ClassCastException from hibernate trying to persist a new EMap entry.
[Teneo] ClassCastException from hibernate trying to persist a new EMap entry. [message #608636] Thu, 05 July 2007 05:19
Chris Hines is currently offline Chris HinesFriend
Messages: 15
Registered: July 2009
Junior Member
I just upgraded to Eclipse 3.3, EMF 2.3, and Teneo 0.8 (I200704230019) from
Eclipse 3.2 EMF 2.2 and Teneo 0.7.5 and I'm encountering an error during
regression testing of my project.

I have an EMF model that includes the following classes:

<eClassifiers xsi:type="ecore:EEnum" name="Type">
<eLiterals name="Started" literal="STARTED"/>
<eLiterals name="Stopped" value="1" literal="STOPPED"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Event"
instanceClassName="java.util.Map$Entry">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
lowerBound="1"
eType="#//playtimehistory/Type"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="time"
lowerBound="1"
eType="#//DateTime"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="key"
lowerBound="1" eType="#//DateTime"
volatile="true" transient="true" derived="true"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
lowerBound="1"
eType="#//playtimehistory/Type" volatile="true" transient="true"
derived="true"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="PlaytimeHistory">
<eStructuralFeatures xsi:type="ecore:EReference" name="events"
upperBound="-1"
eType="#//playtimehistory/Event" containment="true"
eKeys="#//playtimehistory/Event/time"/>
</eClassifiers>

My code lets Teneo use an in-memory Hibernate mapping. A mapping file
generated using the Teneo context menu on my Ecore file contains the
following relevant sections (with some java base packages and URLs edited
for privacy reasons):

<class name="model.playtimehistory.impl.EventImpl" entity-name="Event"
abstract="false" lazy="false" discriminator-value="Event" table="`event`">
<meta attribute="eclassName">Event</meta>
<meta attribute="epackage">http://PlaytimeHistory</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<property name="type" lazy="false" not-null="true" insert="true"
update="true" unique="false">
<column not-null="true" unique="false" name="`type`"/>
<type name="org.eclipse.emf.teneo.hibernate.mapping.ENumUserType" >
<param name="enumClass">model.playtimehistory.Type</param>
</type>
</property>
<property name="time" lazy="false" insert="true" update="true"
not-null="true" unique="false" type="model.DateTime">
<column not-null="true" unique="false" name="`time`"/>
</property>
</class>
<class name="model.playtimehistory.impl.PlaytimeHistoryImpl"
entity-name="PlaytimeHistory" abstract="false" lazy="false"
discriminator-value="PlaytimeHistory" table="`playtimehistory`">
<meta attribute="eclassName">PlaytimeHistory</meta>
<meta attribute="epackage">http://PlaytimeHistory</meta>
<id type="long" name="e_id" column="e_id"
access=" org.eclipse.emf.teneo.hibernate.mapping.identifier.Identifie rPropertyHandler ">
<meta attribute="syntheticId">true</meta>
<generator class="native"/>
</id>
<discriminator column="`dtype`" type="string"/>
<version name="e_version" column="e_version"
access=" org.eclipse.emf.teneo.hibernate.mapping.property.VersionProp ertyHandler ">
<meta attribute="syntheticVersion">true</meta>
</version>
<list name="events" lazy="true" cascade="all,delete-orphan">
<key update="true">
<column name="`playtimehistory_events_e_id`" not-null="false"
unique="false"/>
</key>
<list-index column="`playtimehistory_events_idx`"/>
<one-to-many entity-name="Event"/>
</list>
</class>

In short I have a class with a member of type "EMap<DateTime, Type>" named
"events" that gets mapped to a "list" in Hibernate. When my application
adds an entry to the map and saves the model (using a Hibernate EMF
Resource) I get a ClassCastException from deep in the bowels of Hibernate (v
3.2.3ga). Hibernate is trying to cast a BasicEMap$DelegatingMap to a
java.lang.Collection. Here's the stack trace:

java.lang.ClassCastException:
org.eclipse.emf.common.util.BasicEMap$DelegatingMap
at
org.hibernate.type.CollectionType.getElementsIterator(Collec tionType.java:211)
at
org.hibernate.type.CollectionType.getElementsIterator(Collec tionType.java:200)
at
org.hibernate.engine.CascadingAction.getLoadedElementsIterat or(CascadingAction.java:425)
at
org.hibernate.engine.CascadingAction$1.getCascadableChildren Iterator(CascadingAction.java:222)
at org.hibernate.engine.Cascade.cascadeCollectionElements(Casca de.java:294)
at org.hibernate.engine.Cascade.cascadeCollection(Cascade.java: 242)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :219)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractSaveEventListener.cascadeAft erSave(AbstractSaveEventListener.java:456)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav eOrReplicate(AbstractSaveEventListener.java:334)
at
org.hibernate.event.def.AbstractSaveEventListener.performSav e(AbstractSaveEventListener.java:181)
at
org.hibernate.event.def.AbstractSaveEventListener.saveWithGe neratedId(AbstractSaveEventListener.java:107)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.sav eWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener .java:187)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.ent ityIsTransient(DefaultSaveOrUpdateEventListener.java:172)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.per formSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:94)
at
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onS aveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
at org.hibernate.impl.SessionImpl.fireSaveOrUpdate(SessionImpl. java:507)
at org.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java :499)
at org.hibernate.engine.CascadingAction$1.cascade(CascadingActi on.java:218)
at org.hibernate.engine.Cascade.cascadeToOne(Cascade.java:268)
at org.hibernate.engine.Cascade.cascadeAssociation(Cascade.java :216)
at org.hibernate.engine.Cascade.cascadeProperty(Cascade.java:16 9)
at org.hibernate.engine.Cascade.cascade(Cascade.java:130)
at
org.hibernate.event.def.AbstractFlushingEventListener.cascad eOnFlush(AbstractFlushingEventListener.java:131)
at
org.hibernate.event.def.AbstractFlushingEventListener.prepar eEntityFlushes(AbstractFlushingEventListener.java:122)
at
org.hibernate.event.def.AbstractFlushingEventListener.flushE verythingToExecutions(AbstractFlushingEventListener.java:65)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(De faultFlushEventListener.java:26)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at
org.eclipse.emf.teneo.hibernate.HbSessionWrapper.flush(HbSes sionWrapper.java:153)
at
org.eclipse.emf.teneo.hibernate.resource.HibernateResource.s aveResource(HibernateResource.java:349)

This code was working fine on the previous versions of the tool chain. Any
ideas what is broken? Is it my model, Teneo, or Hibernate?

Thanks,
Chris
Previous Topic:[EMF Compare] Will there be an europa compliant build soon?
Next Topic:[EMF Compare] Questions wrt EMF-DIFF file
Goto Forum:
  


Current Time: Mon Aug 08 23:13:16 GMT 2022

Powered by FUDForum. Page generated in 0.02114 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top