Esempio n. 1
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)");
   }
 }
Esempio n. 2
0
 /**
  * Retrieves a list of data object for the specified shopid field. To use a wildcard search, use a
  * % in the query.
  *
  * @param shopid the field
  * @return List of Product data objects, empty list in case no results were found.
  */
 public java.util.List findProductByShopid(java.lang.Long shopid) throws GenericBusinessException {
   com.skip.HibernateQueryHelper hibernateTemplate = new com.skip.HibernateQueryHelper();
   try {
     String queryString = "from " + Product.class.getName() + " e where e.shopid like :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);
     List list = hibernateTemplate.list(query);
     return list;
   } finally {
     log.debug("finished findProductByShopid(java.lang.Long shopid)");
   }
 }