1 package org.apache.ojb.broker.prevayler.demo; 2 3 17 18 import org.apache.ojb.broker.query.Query; 19 import org.apache.ojb.broker.query.QueryByCriteria; 20 import org.apache.ojb.tutorial1.Product; 21 22 import java.util.Collection ; 23 24 29 public class UCListAllProducts extends AbstractUseCase 30 { 31 34 public UCListAllProducts(org.apache.ojb.broker.PersistenceBroker b) 35 { 36 super(b); 37 } 38 39 40 public void apply() 41 { 42 System.out.println("The list of available products:"); 43 Query query = new QueryByCriteria(Product.class, null); 46 try 47 { 48 Collection allProducts = broker.getCollectionByQuery(query); 50 java.util.Iterator iter = allProducts.iterator(); 52 while (iter.hasNext()) 53 { 54 System.out.println(iter.next()); 55 } 56 } 57 catch (Throwable t) 58 { 59 t.printStackTrace(); 60 } 61 } 62 63 64 public String getDescription() 65 { 66 return "List all product entries"; 67 } 68 } 69 | Popular Tags |