We have two persistence objects where a hasMany b. So a is a property of b. Now we are creating an object of type b and asign the corresponding a-object to b.
Then we try to save the newly created b object via:
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. In which pitfall did I run here? asked 29.04.2014 at 08:45 Nikel Weis |
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. answered 30.04.2014 at 09:30 Nikel Weis |
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Tags:
Asked: 29.04.2014 at 08:45
Seen: 2,457 times
Last updated: 30.04.2014 at 09:30
I think your problem is hibernate related. I guess you did not save 'a' first. so there is no actual (database wise) connection to b. But to be able to save 'b' with a reference to 'a' you must save 'a' first. So if you do save 'a' first and then execute your line it should be fine.
Thanks for your reply. A already exists in the database. The a-object is determined by object b which contains the id of a (contents of object b are from a third-party system and the object shall be created in the database). With that id given object a is fetched from the database. So that should actually not be the problem.