So I'm having a strange problem with the Db4o API. I'm trying to retrieve certain classes of objects (depending on a user's query, but that's not really relevant), from a database. The database definitely has objects with the classes I want to retrieve. So for example, when I queryByExample() for just any Object, and then print out the Classes of each element of the object set, like so...
public void evaluateQuery(ObjectContainer db) {
if (this.hasPredicate) {
;
} else {
if (this.isNode) {
ObjectSet nodes = db.queryByExample(Object.class);
ListIterator listIter = nodes.listIterator();
while (listIter.hasNext()) {
Object node = listIter.next();
System.out.println("Object has Class: " + node.getClass());
}
}
}
}
... and I get a result like this...
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class Node
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
Object has Class: class SubNode
...As you can see, the database has object with Classes set to Node and SubNode. Now, I'd like the code to actually work like this...
public void evaluateQuery(ObjectContainer db) {
if (this.hasPredicate) {
;
} else {
if (this.isNode) {
ObjectSet<Node> nodes = db.queryByExample(Node.class);
ListIterator<Node> listIter = nodes.listIterator();
while (listIter.hasNext()) {
Node node = listIter.next();
System.out.println("Object has Class: " + node.getClass());
}
}
}
.. but when I do this, the ObjectSet is invariably empty, and I can't seem to figure out why. I load a certain subset of Classes, such as the above Node Class, into the environment with ClassLoader at runtime, and they're definitely in there, as I instantiate/use them in other contexts with no problems.