Thanks Cris,
I didn't get to try this yet but are you sure I can match it on a
relationship like "toBudget"? "toBudget" returns the parent object.
Or is matchExp smart enough to guess that I want to match the PK of the
parent object and implicitly say
ExpressionFactory.matchExp("toBudget.budget_key", irf_key)?
In the meantime I used the in-memory queries like this:
Budget budget = (Budget) DataObjectUtils.objectForPK(context,
Budget.class, new Integer(key);
List budget_entries = budget.getBudget_entryArray();
Expression exp =
ExpressionFactory.likeExp("description",this.getDescription());
List finalEntries = exp.filterObjects(entries);
Otherwise we could probably just use a SQLTemplate query right?
Fredrik
> Is it possible to make a query that includes two criteria,
> one of them being the primary key of the parent table. Can I
> include the PK field like a regular field in one of the Expressions?
>
> I know I could retrieve the parent objec, get the array of
> child objects and search that list for the object I'm looking
> for but I'm thinking there must be an easier way.
>
> SelectQuery query = new SelectQuery(Budget_entry.class);
>
> query.setQualifier(Expression.fromString("description =
> '"+this.getDescription()+"'"));
> query.andQualifier(Expression.fromString("toBudget.budget_key=
> '"+irf_key
> +"'"));
>
Though I don't like to admit it, I have on a few occasions done
something
like this:
ExpressionFactory.matchExp("toBudget", irf_key);
No need to reference the pk field, though if you want to be explicit,
you
need to use a db: prefix or matchDbExp.
Cris
This archive was generated by hypermail 2.0.0 : Thu Mar 24 2005 - 13:09:54 EST