Okay I did the following:
- Remove the code which enables cascade on update. It is disabled by
default, right?
- Make all Freetalk objects store() their non-primitive member objects on
their own.
- class Message does not store(mAuthor) because the identities are stored by
the WoTIdentityManager. It does store(this) which should store the mAuthor
reference but not the referenced object itself, right?
- Add the following code to class Message:
public void store() {
/* FIXME: Check for duplicates */
if(db.ext().isStored(this) && !db.ext().isActive(this))
throw new RuntimeException("Trying to store a non-active
Message object");
if(mAuthor == null)
throw new RuntimeException("Trying to store a message with
mAuthor == null");
.......
...
}
public FTIdentity getAuthor() {
db.activate(this, 3);
if(mAuthor == null)
throw new RuntimeException("mAuthor == null");
.....
...
}
Now the following happens: None of the RuntimeException in store() is
thrown, so the Message objects are definitely stored with mAuthor != null.
However, getAuthor() throws because mAuthor == null.
Now this is weird!