Here a part of the class hierarchy that I'm persisting:
abstract class AbstractViewNode implements ViewNode {
private String _path;
public final String getPath() {
if (_path == null) {
_path = ...
}
return _path;
}
}
abstract class AbstractResourceNode extends AbstractViewNode implements ResourceNode {
private ResourceID _rid;
public final ResourceID getResourceID() {
return _rid;
}
}
final class InstanceNodeImpl extends AbstractResourceNode implements InstanceNode {
// ....
}
Before opening db, I set indexing for fields "_path" and "_rid" on their respective classes (using ClassLoader#loadClass(), since classes are package private). db4o messageLevel(1) shows me that both are indexed, but, Diagnosis class (when I enable that logging) shows that "_path" is not indexed.
Now, I implemented both NQ and SODA queries (as it seems that NQs don't get optimised, as reported in my previous post). NQ works correctly for both, but is not optimised. SODA query correctly works for the field "_rid", but fails for the field "_path".
// not working:
@SuppressWarnings("unchecked")
List<ResourceNode> sodaFindForPath(String path) {
Query query = getDb().query();
query.constrain(ResourceNode.class);
query.descend("_path").constrain(path);
return new ArrayList<ResourceNode>(query.execute());
}
// working:
@SuppressWarnings("unchecked")
List<ResourceNode> sodaFindForId(ResourceID id) {
Query query = getDb().query();
query.constrain(ResourceNode.class);
query.descend("_rid").constrain(id);
return new ArrayList<ResourceNode>(query.execute());
}
I don't know whether the non-working SODA query on "_path" field is related to the fact that the field is lazily initialised? That is the only difference I see between the two queries. However, since messageLevel(1) and db4o Diagnosis give me different reports, I'm wondering whether there is something else involved?
Thanks in advance for any hint.