Hi,
I'm quite new to JDO and wanted to ask if it is possible to filter using complex objects. I know that you can do something like this:
Query q = pm.newQuery(MyClass.class, "field1 < value");
q.declareParameters("int value");
List results = q.execute(205);
Iterator iter = results.iterator();
But assume I have the following situation:
@PersistenceCapable(...)
class ParentObj{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
String id;
...
@Persistent
ChildObj child;
}
@PersistenceCapable(...)
class ChildObj{
@Persistent
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
String id;
...
}
Now assume I want to filter all ParentObj
objects that have some given ChildObj
. I have
public List<ParentObj> getAllParentObjBy(ChildObj child){
PersistenceManager pm = ...
Query query = pm.newQuery(ParentObj.class, "child = childVal");
query.declareParameters("ChildObj childVal");
Collection result = (Collection)query.execute(child);
//???
return result;
}
This is very pseudocode, but I hope the idea is clear. Can I somehow use the Query object like in the first example but in this case with the child
instance?