db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oliver.m...@ppi.de
Subject query-customizers and path-expressions, was: subqueries
Date Mon, 25 Aug 2003 13:35:14 GMT

I have a proposal for a new feature I would like
to discuss.  I had started this as a question in the
Users' list.

> -----Original Message-----
> From: oliver.matz@ppi.de [mailto:oliver.matz@ppi.de]

> I have a model of the form
>     [A] <--1--n--> [B] --1--1--> [C]
> I can formulate org.apache.ojb.broker.query.Criteria critB
> to specify a particular set of B instances.
> Now I would like to formulate a query 
> for all A instances for which there is a B-instance that
>      matches critB and has a reference to a specific C-instance z.

One elegant way to do this is to have a collection field 
A.mySpecialBs with a query-customizer which adds the critB-specific 
criteria to the OJB-generated query that retrieves that collection.

However, if I do a query on class A with a criterion
that uses a path-expression, i.e.,
 Criteria.addEqualTo("mySpecialBs.myC", value),
then the query-customizer is not being invoked.

Proposal: I would like to add a "criteria-customizer" 
(analogous to the query-customizer), where 
CriteriaCustomizer is an interface with a method

  Criteria customizeCriteria(Object anObject, 
       PersistenceBroker aBroker, 
       CollectionDescriptor aCod, Criteria aCrit);

OJB should invoke that CriteriaCustomizer analogously to a 
Besides, when OJB resolves path expressions
(inside SqlQueryStatement.appendWhereClause()),
it should invoke that CriteriaCustomizer as well.

This way, the criteria-customizer becomes a transparent detail
of the O/R-mapping.

What do you think?


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message