Is it always true that you don’t have to use add() when you set a property of an entity which is already added?


entity User {
username : String
}

entity Article {
user : User
body : String
}

var us = User()
var a = Article()

add(us);

a.user = us;

Submitted by Terje Pedersen on 15 April 2011 at 09:08

On 15 April 2011 at 09:16 Zef Hemel commented:

I would guess, but maybe I’m wrong that when you execute the code you show, the Article would not be persisted. The other way around, would persist both objects (add(a) instead of add(us)). Otherwise you could end up with an inconsistent database (pointing to objects that don’t exist). The same holds for adding to Collections.


On 15 April 2011 at 09:24 Terje Pedersen commented:

I haven’t tested the code above, but when I used like Article(user=us) it got persisted without using add() on the Article. But thats ok, I only had to add a.user afterwards instead of ending up with empty articles everytime you click on add new article.


On 11 May 2011 at 16:30 Zef Hemel closed this issue.

Log in to post comments