protected List<DDMStructure> doFindByC_G_C_N_D_S_T_S(
      long companyId,
      long[] groupIds,
      long classNameId,
      String[] names,
      String[] descriptions,
      String storageType,
      int type,
      int status,
      boolean andOperator,
      int start,
      int end,
      OrderByComparator<DDMStructure> orderByComparator,
      boolean inlineSQLHelper) {

    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(FIND_BY_C_G_C_N_D_S_T_R);

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql,
                DDMStructurePermission.getStructureModelResourceName(classNameId),
                "DDMStructure.structureId",
                groupIds);
      }

      sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds));
      sql = StringUtil.replace(sql, "[$STATUS$]", getStatus(status));
      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "lower(CAST_TEXT(DDMStructure.name))", StringPool.LIKE, false, names);
      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "DDMStructure.description", StringPool.LIKE, true, descriptions);
      sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

      if (orderByComparator != null) {
        sql = CustomSQLUtil.replaceOrderBy(sql, orderByComparator);
      }

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addEntity("DDMStructure", DDMStructureImpl.class);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(companyId);

      if (groupIds != null) {
        qPos.add(groupIds);
      }

      qPos.add(classNameId);
      qPos.add(names, 2);
      qPos.add(descriptions, 2);
      qPos.add(storageType);
      qPos.add(storageType);
      qPos.add(type);

      if (status != WorkflowConstants.STATUS_ANY) {
        qPos.add(status);
      }

      return (List<DDMStructure>) QueryUtil.list(q, getDialect(), start, end);
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }
  protected int doCountByC_G_C_N_D_S_T_S(
      long companyId,
      long[] groupIds,
      long classNameId,
      String[] names,
      String[] descriptions,
      String storageType,
      int type,
      int status,
      boolean andOperator,
      boolean inlineSQLHelper) {

    names = CustomSQLUtil.keywords(names);
    descriptions = CustomSQLUtil.keywords(descriptions, false);

    Session session = null;

    try {
      session = openSession();

      String sql = CustomSQLUtil.get(COUNT_BY_C_G_C_N_D_S_T_S);

      if (inlineSQLHelper) {
        sql =
            InlineSQLHelperUtil.replacePermissionCheck(
                sql,
                DDMStructurePermission.getStructureModelResourceName(classNameId),
                "DDMStructure.structureId",
                groupIds);
      }

      sql = StringUtil.replace(sql, "[$GROUP_ID$]", getGroupIds(groupIds));
      sql = StringUtil.replace(sql, "[$STATUS$]", getStatus(status));
      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "lower(CAST_TEXT(DDMStructure.name))", StringPool.LIKE, false, names);

      sql =
          CustomSQLUtil.replaceKeywords(
              sql, "DDMStructure.description", StringPool.LIKE, true, descriptions);

      sql = CustomSQLUtil.replaceAndOperator(sql, andOperator);

      SQLQuery q = session.createSynchronizedSQLQuery(sql);

      q.addScalar(COUNT_COLUMN_NAME, Type.LONG);

      QueryPos qPos = QueryPos.getInstance(q);

      qPos.add(companyId);

      if (groupIds != null) {
        qPos.add(groupIds);
      }

      qPos.add(classNameId);
      qPos.add(names, 2);
      qPos.add(descriptions, 2);
      qPos.add(storageType);
      qPos.add(storageType);
      qPos.add(type);

      if (status != WorkflowConstants.STATUS_ANY) {
        qPos.add(status);
      }

      Iterator<Long> itr = q.iterate();

      if (itr.hasNext()) {
        Long count = itr.next();

        if (count != null) {
          return count.intValue();
        }
      }

      return 0;
    } catch (Exception e) {
      throw new SystemException(e);
    } finally {
      closeSession(session);
    }
  }