Example #1
0
 /**
  * Obtains the total number of product objects in the database.
  *
  * @return an integer value.
  */
 public int getProductListSize() throws GenericBusinessException {
   com.skip.HibernateQueryHelper hibernateTemplate = new com.skip.HibernateQueryHelper();
   try {
     String queryString = "select count(*) from " + Product.class.getName();
     Query query = hibernateTemplate.createQuery(queryString);
     List list = hibernateTemplate.list(query);
     Integer countResult = (Integer) list.get(0);
     return countResult.intValue();
   } finally {
     log.debug("finished getProductListSize()");
   }
 }
Example #2
0
 public Product findProductByShopidAndBarcode(Long shopid, String barcode)
     throws com.skip.exception.GenericBusinessException {
   com.skip.HibernateQueryHelper hibernateTemplate = new com.skip.HibernateQueryHelper();
   try {
     String queryString =
         "from "
             + Product.class.getName()
             + " e where e.barcode like :barcode and e.shopid = :shopid";
     // Add a an order by on all primary keys to assure reproducable results.
     String orderByPart = "";
     orderByPart += " order by e.productid";
     queryString += orderByPart;
     Query query = hibernateTemplate.createQuery(queryString);
     hibernateTemplate.setQueryParameter(query, "shopid", shopid);
     hibernateTemplate.setQueryParameter(query, "barcode", barcode);
     List list = hibernateTemplate.list(query);
     if (!list.isEmpty()) {
       return (Product) list.get(0);
     }
     return null;
   } finally {
     log.debug("finished findProductByShopidAndBarcode(Long shopid, String barcode)");
   }
 }