1 package org.apache.ojb.tutorial1; 2 3 17 18 import org.apache.ojb.broker.PersistenceBroker; 19 import org.apache.ojb.broker.query.Query; 20 import org.apache.ojb.broker.query.QueryByCriteria; 21 22 import java.util.Collection ; 23 import java.util.Iterator ; 24 25 28 public class UCListAllProducts extends AbstractUseCase 29 { 30 35 public UCListAllProducts(PersistenceBroker broker) 36 { 37 super(broker); 38 } 39 40 45 public String getDescription() 46 { 47 return "List all product entries"; 48 } 49 50 53 public void apply() 54 { 55 System.out.println("The list of available products:"); 56 57 Query query = new QueryByCriteria(Product.class, null); 60 61 try 62 { 63 Collection allProducts = broker.getCollectionByQuery(query); 65 66 for (Iterator iter = allProducts.iterator(); iter.hasNext();) 68 { 69 System.out.println(iter.next()); 70 } 71 } 72 catch (Throwable t) 73 { 74 t.printStackTrace(); 75 } 76 } 77 } 78 | Popular Tags |