|
Re: [Teneo] Import XMI EMF Model [message #1690534 is a reply to message #1690496] |
Sat, 28 March 2015 07:50 |
Martin Taal 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.01845 seconds