> -----Original Message----- > From: Matthew Toseland [mailto:toad at amphibian.dyndns.org] > Sent: Monday, December 15, 2008 7:30 PM > To: xor > Subject: Re: I need help with Db4o / Freetalk > > On Monday 15 December 2008 13:45, you wrote: > > > > Hi, > > > > there is a severe Db4o problem in Freetalk: > > Instances of class Message can only be created with a > non-null member > > variable mAuthor. Further, mAuthor is final. So when receiving > > messages, the mAuthor field is definitely non-null when the Message > > objects are stored in the database. > > > > HOWEVER, when retrieving the Message objects from the > database, their > > mAuthor field is null! > > This also only happens on my normal node, if I run a node in the > > debugger, it does not happen. > > > > The worst thing is: The problem is NOT that the Message objects are > > not fully activated. > > The plugin does a query at startup to find messages with mAuthor == > > null by > > doing: > > > > Query q = db.query(); > > q.constrain(Message.class); > > q.descend("mAuthor").constrain(null).identity(); > > ObjectSet<Message> brokenMessages = q.execute(); for(Message m : > > brokenMessages) { > > Logger.error(m, "Deleting message with mAuthor == null: " + > > m.getURI()); > > db.delete(m); > > } > > Do you double check that it is in fact null?
constrain(null).identity() should do a DEFINITE check whether it is null, shouldn't it? > What is the query activation depth set to? Configuration dbCfg = Db4o.newConfiguration(); dbCfg.reflectWith(new JdkReflector(mClassLoader)); dbCfg.activationDepth(5); /* FIXME: Figure out a reasonable value */ > > > > This query always deletes all messages. Therefore, the > mAuthor member > > variable is really null. > > I do not have any clue why this happens. > > The WoTIdentityManager definitely does db.store(), db.commit() on > > importet identities. > > > > And the message fetcher even receives the authors by a > DATABASE QUERY, > > so the authors ARE in the database, but the member field of the > > Messages gets set to null! Damn... > > > > Any ideas? This currently prevents Freetalk from being useable... > > I don't know. I presume a lot of code deals with these, or > points to them ... > IIRC you don't do any manual activation or deactivation, but > it remains possible that a Message could be only partially > activated - the default depth is 5, this will activate all > objects to a depth of 5 pointer indirections, resulting in > the last objects being instantiated but their members not > activated ... I even added a db.activate(this, 5); in the getAuthor() function of Message and it did not help. > You could use the ObjectCallbacks API to check whether > mAuthor is null when storing a Message. You could also use > container.ext.isActive() to check your assumptions about activation. The constructor of Message throws an exception when trying to construct a message with author == null so it is not possible that it is null when storing. > Let me know how it goes. Unfortunately I do not have any clue how to fix this :(
