db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b..@apache.org
Subject cvs commit: db-ojb/src/samples/org/apache/ojb/tutorials PBExample.java
Date Fri, 27 Aug 2004 20:00:35 GMT
brj         2004/08/27 13:00:35

  Modified:    src/samples/org/apache/ojb/tutorials PBExample.java
  Log:
  use QueryFactory to build the query
  
  Revision  Changes    Path
  1.3       +15 -13    db-ojb/src/samples/org/apache/ojb/tutorials/PBExample.java
  
  Index: PBExample.java
  ===================================================================
  RCS file: /home/cvs/db-ojb/src/samples/org/apache/ojb/tutorials/PBExample.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PBExample.java	22 Jun 2004 22:34:01 -0000	1.2
  +++ PBExample.java	27 Aug 2004 20:00:35 -0000	1.3
  @@ -21,7 +21,9 @@
   import org.apache.ojb.broker.PersistenceBrokerException;
   import org.apache.ojb.broker.PersistenceBrokerFactory;
   import org.apache.ojb.broker.query.Criteria;
  +import org.apache.ojb.broker.query.Query;
   import org.apache.ojb.broker.query.QueryByCriteria;
  +import org.apache.ojb.broker.query.QueryFactory;
   
   /**
    * PB-api usage examples.
  @@ -110,15 +112,15 @@
       public static Product findByTemplate(Product template)
       {
           PersistenceBroker broker = null;
  -        Product           result = null;
  +        Product result = null;
   
           try
           {
               broker = PersistenceBrokerFactory.defaultPersistenceBroker();
   
  -            QueryByCriteria query = new QueryByCriteria(template);
  +            Query query = QueryFactory.newQueryByExample(template);
   
  -            result = (Product)broker.getObjectByQuery(query);
  +            result = (Product) broker.getObjectByQuery(query);
           }
           finally
           {
  @@ -138,8 +140,8 @@
        */
       public static Collection getExpensiveLowStockProducts()
       {
  -        PersistenceBroker broker  = null;
  -        Collection        results = null;
  +        PersistenceBroker broker = null;
  +        Collection results = null;
   
           try
           {
  @@ -177,14 +179,14 @@
       public static boolean sellOneProduct(Product template)
       {
           PersistenceBroker broker = null;
  -        boolean           isSold = false;
  +        boolean isSold = false;
   
           try
           {
               broker = PersistenceBrokerFactory.defaultPersistenceBroker();
   
  -            QueryByCriteria query  = new QueryByCriteria(template);
  -            Product         result = (Product)broker.getObjectByQuery(query);
  +            Query query = QueryFactory.newQueryByExample(template);
  +            Product result = (Product) broker.getObjectByQuery(query);
   
               if (result != null)
               {
  @@ -225,15 +227,15 @@
        */
       public static boolean findAndDeleteProduct(Product template)
       {
  -        PersistenceBroker broker    = null;
  -        boolean           isDeleted = false;
  +        PersistenceBroker broker = null;
  +        boolean isDeleted = false;
   
           try
           {
               broker = PersistenceBrokerFactory.defaultPersistenceBroker();
   
  -            QueryByCriteria query  = new QueryByCriteria(template);
  -            Product         result = (Product)broker.getObjectByQuery(query);
  +            Query query = QueryFactory.newQueryByExample(template);
  +            Product result = (Product) broker.getObjectByQuery(query);
   
               if (result != null)
               {
  
  
  

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


Mime
View raw message