db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ilkka Priha <ipr...@surfeu.fi>
Subject [patch] QueryFactory doesn't return queries by samples
Date Tue, 10 Jun 2003 18:48:37 GMT
Hi

Documentation of QueryFactory claims to return either an identity query
or a sample query when giving only one Object argument. However, the
implementation returns always an identity query, which is useless when
trying to query other object attributes than the primary key. Below is a
patch correcting the implementation (there is already a comment, which
perhaps suggests this kind of patch?).

-- Ilkka

+++ org.apache.ojb.broker.query.QueryFactory.java

      /**
       * Method declaration
       * @param example_or_identity
       * @return
       */
      public static Query newQuery(Object example_or_identity)
      {
          /**
           * should add criteria here.
           */
-        return new QueryByIdentity(example_or_identity);
+        return example_or_identity instanceof Identity ?
+            new QueryByIdentity(example_or_identity) :
+            new QueryByCriteria(example_or_identity);
      }






Mime
View raw message