Esempio n. 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()");
   }
 }
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)");
   }
 }
Esempio n. 3
0
  /**
   * Returns a list of all product instances.
   *
   * @return a list of Product objects.
   */
  public List getProductList() throws GenericBusinessException {
    com.skip.HibernateQueryHelper hibernateTemplate = new com.skip.HibernateQueryHelper();
    try {

      String queryString = "from " + Product.class.getName() + " e";
      // 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);
      List list = hibernateTemplate.list(query);

      return list;
    } finally {
      log.debug("finished getProductList");
    }
  }
Esempio n. 4
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. 5
0
 /**
  * Returns a subset of all product instances.
  *
  * @param startIndex the start index within the result set (1 = first record); any zero/negative
  *     values are regarded as 1, and any values greater than or equal to the total number of
  *     product instances will simply return an empty set.
  * @param endIndex the end index within the result set (<code>getProductListSize()</code> = last
  *     record), any values greater than or equal to the total number of product instances will
  *     cause the full set to be returned.
  * @return a list of Product objects, of size <code>(endIndex - startIndex)</code>.
  */
 public List getProductList(int startIndex, int endIndex) throws GenericBusinessException {
   if (startIndex < 1) {
     startIndex = 1;
   }
   if ((endIndex - startIndex) < 0) {
     // Just return an empty list.
     return new ArrayList();
   }
   com.skip.HibernateQueryHelper hibernateTemplate = new com.skip.HibernateQueryHelper();
   try {
     String queryString = "from " + Product.class.getName() + " e";
     // 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);
     query.setFirstResult(startIndex - 1);
     query.setMaxResults(endIndex - startIndex + 1);
     List list = hibernateTemplate.list(query);
     return list;
   } finally {
     log.debug("finished getProductList(int startIndex, int endIndex)");
   }
 }