Hello everybody,

Recently, I asked a question how can a query an object having a property which is a collection of objects. I received an answer, so, now my query looks like this:

public static Collection findModelsByReactionsName(String rName) {

PersistenceBroker broker = PersistenceBrokerFactory.defaultPersistenceBroker();

    try{
      Criteria crit = new Criteria();
      crit.addLike("reactions.name", rName);
      QueryByCriteria query = new QueryByCriteria(Model.class, crit);
      return broker.getCollectionByQuery(query);
    } finally {
      broker.close();
    }
  }

Now, I have another problem. There are several subclasses of Reaction. Those subclasses of course have their own properties. For example, "BidirectionalReaction" has a property "reverseRate". I want to query the models by this property which implies that I am looking only for the models that have BidirectionalReactions in them. But I don't know how to do that. If I just specify "reactions.reverseRate" in the query, OJB generates SQL that would try to query using all the possibe subclasses. The SQL of course fails since only one table would have a column corresponding to reverseRate.

How do I write such a query?

thanks a lot,

Kirill

PS

Here is explanation of my object model:

I have an object model in which there are two objects: Model and
Reactiont. This is basically n to m relationship. Model can have a number of Reactions. Reactions can be in a number of Models.
In Java this is implemented by a Collection property in Model class.

I want to construct a query that allows me to find all the models that
have a particular reaction in them.



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to