<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Answers to: Persistence Object is not saved - ForeignKey is Null.</title><link>https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-null</link><description>&lt;p&gt;We have two persistence objects where a hasMany b. So a is a property of b.&lt;/p&gt;
&lt;p&gt;Now we are creating an object of type b and asign the corresponding a-object to b. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;b.a = a;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then we try to save the newly created b object via:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ivy.persistence.persistenceUnit.merge(b);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then it throws an error that the ForeignKey of a in table b cannot be null. But in the debugger object a is assigned correctly to object b.&lt;/p&gt;
&lt;p&gt;In which pitfall did I run here?&lt;/p&gt;</description><atom:link href="https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-null" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 30 Apr 2014 09:30:42 -0400</lastBuildDate><item><title>Answer by Nikel Weis</title><link>https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-null/671</link><description>&lt;p&gt;Hmm... ok it was indeed an Xpert.ivy related pitfall. Kind of embarrassing but I want to avoid anyone else spends time on that. It is possible to set "not insertable" and "not updatable" in the Data Class definition. AND THAT'S WHAT HAPPENS INDEED! No records can be inserted or updated from the program logic layer. &lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Nikel Weis</dc:creator><pubDate>Wed, 30 Apr 2014 09:30:42 -0400</pubDate><guid>https://answers.axonivy.com/questions/667/persistence-object-is-not-saved-foreignkey-is-null/671</guid></item></channel></rss>