Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] List as Map-value
[Teneo] List as Map-value [message #1729801] Tue, 19 April 2016 07:50 Go to next message
Sven Meisinger is currently offline Sven MeisingerFriend
Messages: 2
Registered: April 2016
Junior Member
Hi everyone,

I'm trying to create a map, that has lists as entry-values.
I implemented the functionality as described here:
https://www.eclipse.org/forums/index.php/t/400216/
MyObj test = factory.createMyObj();
EList<EObject> myList = ECollections.emptyEList();
test.getMyMap.put("x", myList);


With XML as as storage it works fine.
But if I use teneo and a MySql-db it doesn't work! Any tipps what I'm doing wrong?

The myMap-Attribute is modeled with

  • containment=true
  • upperBound = -1

and the entry is modeled with

  • Name = StringToAny
  • Instance TypeName = Java.util.Map$Entry
  • Attribute: Name = key, EType = EString
  • Attribute: Name = value, EType = EObject, upperBound = -1


The following exception stack is thrown:
org.hibernate.MappingException: Unknown entity: org.eclipse.emf.ecore.util.EObjectResolvingEList
	at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
	at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1443)
	at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:242)
	at org.hibernate.event.internal.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:511)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:100)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
	at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
	at org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:235)
	at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:350)
	at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:293)
	at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
	at org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:379)
	at org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:319)
	at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:296)
	at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
	at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:118)
	at org.hibernate.event.internal.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:460)
	at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:294)
	at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
	at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
	at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:671)
	at org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdate(HbSessionWrapper.java:166)
	at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:380)
	at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:422)
	at startup.StartUp.createPart(StartUp.java:41)
	at startup.StartUp.main(StartUp.java:25)
Apr 19, 2016 9:30:03 AM org.eclipse.emf.teneo.hibernate.HbMapperException <init>
SCHWERWIEGEND: Exception when saving resource test
org.hibernate.MappingException: Unknown entity: org.eclipse.emf.ecore.util.EObjectResolvingEList
	at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1096)
	at org.hibernate.internal.SessionImpl.getEntityPersister(SessionImpl.java:1443)
	at org.hibernate.engine.internal.ForeignKeys.isTransient(ForeignKeys.java:242)
	at org.hibernate.event.internal.AbstractSaveEventListener.getEntityState(AbstractSaveEventListener.java:511)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:100)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
	at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
	at org.hibernate.engine.spi.CascadingActions$5.cascade(CascadingActions.java:235)
	at org.hibernate.engine.internal.Cascade.cascadeToOne(Cascade.java:350)
	at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:293)
	at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
	at org.hibernate.engine.internal.Cascade.cascadeCollectionElements(Cascade.java:379)
	at org.hibernate.engine.internal.Cascade.cascadeCollection(Cascade.java:319)
	at org.hibernate.engine.internal.Cascade.cascadeAssociation(Cascade.java:296)
	at org.hibernate.engine.internal.Cascade.cascadeProperty(Cascade.java:161)
	at org.hibernate.engine.internal.Cascade.cascade(Cascade.java:118)
	at org.hibernate.event.internal.AbstractSaveEventListener.cascadeAfterSave(AbstractSaveEventListener.java:460)
	at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:294)
	at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:194)
	at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:125)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:209)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:194)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.performSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:114)
	at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:90)
	at org.hibernate.internal.SessionImpl.fireSaveOrUpdate(SessionImpl.java:684)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:676)
	at org.hibernate.internal.SessionImpl.saveOrUpdate(SessionImpl.java:671)
	at org.eclipse.emf.teneo.hibernate.HbSessionWrapper.saveOrUpdate(HbSessionWrapper.java:166)
	at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:380)
	at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:422)
	at startup.StartUp.createPart(StartUp.java:41)
	at startup.StartUp.main(StartUp.java:25)

java.lang.IllegalStateException: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: java.util.Map$Entry
	at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:425)
	at startup.StartUp.createPart(StartUp.java:41)
	at startup.StartUp.main(StartUp.java:25)
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: java.util.Map$Entry
	at org.hibernate.internal.SessionImpl.throwTransientObjectException(SessionImpl.java:1941)
	at org.hibernate.internal.SessionImpl.getEntityName(SessionImpl.java:1935)
	at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.beforeSaveRollback(HibernateResource.java:433)
	at org.eclipse.emf.teneo.hibernate.resource.HibernateResource.saveResource(HibernateResource.java:412)
	at org.eclipse.emf.teneo.resource.StoreResource.save(StoreResource.java:422)
	... 2 more
Re: [Teneo] List as Map-value [message #1729841 is a reply to message #1729801] Tue, 19 April 2016 12:47 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hey Sven,
To be honest I don't think Hibernate supports mapping a Map with as values a Collection. But if you can find an example on the net somewhere I can take a look on how to do this with Teneo.

gr. Martin
Re: [Teneo] List as Map-value [message #1730191 is a reply to message #1729841] Fri, 22 April 2016 08:11 Go to previous message
Sven Meisinger is currently offline Sven MeisingerFriend
Messages: 2
Registered: April 2016
Junior Member
Hi Martin,
thank you for your fast response and clear statement.

I don't know much about Hibernate and it's one of the reasons, why we choose EMF and teneo: We saw the chance, that we do not need to deal with Hibernate and that it's completely encapsulated.

With my little knowledge I found following blog entry:
http://blog.xebia.com/mapping-multimaps-with-hibernate/

I don't know if this is the right/possible way of dealing with the problem. But I still hope not having to introduce helperobjects holding a list in our EMF-model.

Regards
Sven

Previous Topic:[EMFForms] Forms integration with Problems View
Next Topic:[EMFStore,ECP] java.lang.RuntimeException: An invalid XML character was found in the element content
Goto Forum:
  


Current Time: Wed Apr 25 12:44:12 GMT 2018

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

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