Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [Teneo] Import XMI EMF Model(How to import EMF model)
[Teneo] Import XMI EMF Model [message #1690496] Fri, 27 March 2015 15:57 Go to next message
Xabier De Carlos is currently offline Xabier De CarlosFriend
Messages: 12
Registered: September 2013
Junior Member
Hi,
I'am trying to import existing EMF model that is persisted using XMI to a HibernateStore using teneo. Teneo is configured to use the EAV mapping schema. First, I load all EPackages of the metamodels and athen add them to the data store using dataStore.setEPackages(ePackages). Then, I load the EMF model within a resource. And finally, I try to copy each Object from EMF model within the Hibernate Data Store using the saveOrUpdate mehtod of Session class:

for (Object o : resource.getContents()) {
    session.saveOrUpdate(o);	
}


However, this fails and it throws next Exception: Exception in thread "main" org.hibernate.PropertyValueException: not-null property references a null or transient value : EAVSingleEAttributeValueHolder.mandatoryValue.

I think that the error comes because some persisted elements contain references to elements that are not already persisted. If it is so, how could I avoid the exception?

Thank you,

Regards,

Xabier De Carlos.



Re: [Teneo] Import XMI EMF Model [message #1690534 is a reply to message #1690496] Sat, 28 March 2015 07:50 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Xabier,
What hibernate does in case of foreign key references (sometimes) first persist A and then B and then store the id of B
in A (assuming A references B). Same as here:
https://forum.hibernate.org/viewtopic.php?f=1&t=955169

But.. I don't have a good solution for this. Sometimes it easiest to make the association non-mandatory, or if there is
a clear order/specific case where this happens make sure to persist objects in the right order.
Using the EMF api (and the runtime model) you can walk over the mandatory references and store the mandatory ones first.
This works as long as you don't have cycles.

gr. Martin

On 27-03-15 16:57, Xabier De Carlos wrote:
> Hi,
> I'am trying to import existing EMF model that is persisted using XMI to a HibernateStore using teneo. Teneo is
> configured to use the EAV mapping schema. First, I load all EPackages of the metamodels and athen add them to the data
> store using dataStore.setEPackages(ePackages). Then, I load the EMF model within a resource. And finally, I try to copy
> each Object from EMF model within the Hibernate Data Store using the saveOrUpdate mehtod of Session class:
>
>
> for (Object o : resource.getContents()) {
> session.saveOrUpdate(o);
> }
>
> However, this fails and it throws next Exception: Exception in thread "main" org.hibernate.PropertyValueException:
> not-null property references a null or transient value : EAVSingleEAttributeValueHolder.mandatoryValue.
> I think that the error comes because some persisted elements contain references to elements that are not already
> persisted. If it is so, how could I avoid the exception?
>
> Thank you,
>
> Regards,
>
> Xabier De Carlos.
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Teneo] Import XMI EMF Model [message #1690682 is a reply to message #1690534] Mon, 30 March 2015 15:16 Go to previous message
Xabier De Carlos is currently offline Xabier De CarlosFriend
Messages: 12
Registered: September 2013
Junior Member
Hi Martin,
Thank you! I will try to use the EMF api to insert elements and properties in the appropiate order.

Cheers,
Xabi.
Previous Topic:[EMFForms] TableControl
Next Topic:[EMFStore]Matching elements by attribute value
Goto Forum:
  


Current Time: Sat Apr 04 15:56:30 GMT 2020

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

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

Back to the top