/**
  * 设置ProductCategory的treepath和grade属性。例如根级分类的treepath为',',grade为‘0’表示顶级分类,
  * 次级分类的treepath为‘,1,’,其中这个1表示根级分类中第一个元素,grade为'1'表示一级分类,以此类推。
  *
  * @param paramProductCategory 某个等级的实例
  * @return
  */
 private void setProductCategoryOfTreepathAndGrade(ProductCategory paramProductCategory) {
   if (paramProductCategory == null) return;
   ProductCategory localProductCategory = paramProductCategory.getParent();
   if (localProductCategory != null)
     paramProductCategory.setTreePath(
         localProductCategory.getTreePath() + localProductCategory.getId() + ",");
   else paramProductCategory.setTreePath(",");
   paramProductCategory.setGrade(Integer.valueOf(paramProductCategory.getTreePaths().size()));
 }
 @Override
 public List<ProductCategory> findParents(ProductCategory productCategory, Integer count) {
   if ((productCategory == null) || (productCategory.getParent() == null))
     return Collections.emptyList();
   String str =
       "select productCategory from ProductCategory productCategory where productCategory.id in (:ids) order by productCategory.grade asc";
   TypedQuery<ProductCategory> localTypedQuery =
       this.getEntityManager()
           .createQuery(str, ProductCategory.class)
           .setFlushMode(FlushModeType.COMMIT)
           .setParameter("ids", productCategory.getTreePaths());
   if (count != null) localTypedQuery.setMaxResults(count.intValue());
   return localTypedQuery.getResultList();
 }