コード例 #1
0
  private String getRelatedParentsByKeyHQL(
      List<ContentKey> contentKeys, boolean includeOnlyMainVersions) {
    final SelectBuilder hqlQuery = new SelectBuilder(0);
    hqlQuery.addSelect("rc.key.childContentKey");
    hqlQuery.addSelectColumn("c");
    hqlQuery.addFromTable(ContentVersionEntity.class.getName(), "cv", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(RelatedContentEntity.class.getName(), "rc", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(ContentEntity.class.getName(), "c", SelectBuilder.NO_JOIN, null);
    // hqlQuery.addFromTable( "c.mainVersion", null, SelectBuilder.LEFT_JOIN_FETCH, null );
    // hqlQuery.addFromTable( "c.sectionContents", null, SelectBuilder.LEFT_JOIN_FETCH, null );
    // hqlQuery.addFromTable( "c.contentHomes", null, SelectBuilder.LEFT_JOIN_FETCH, null );

    if (includeOnlyMainVersions) {
      hqlQuery.addFilter("AND", "c.mainVersion.key = cv.key");
    } else {
      hqlQuery.addFilter("AND", "c.key = cv.content.key");
    }

    hqlQuery.addFilter("AND", "cv.key = rc.key.parentContentVersionKey");

    hqlQuery.addFilter(
        "AND",
        new InClauseBuilder<ContentKey>("rc.key.childContentKey", contentKeys) {
          public void appendValue(StringBuffer sql, ContentKey value) {
            sql.append(value.toString());
          }
        }.toString());

    hqlQuery.addFilter("AND", "c.deleted = 0");
    hqlQuery.addOrderBy("c.createdAt");
    return hqlQuery.toString();
  }
コード例 #2
0
  public String getNumberOfRelatedParentsByKeyHQL(List<ContentKey> contentKeys) {
    final SelectBuilder hqlQuery = new SelectBuilder(0);
    hqlQuery.addSelect("count(*)");
    hqlQuery.addFromTable(ContentVersionEntity.class.getName(), "cv", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(RelatedContentEntity.class.getName(), "rc", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFromTable(ContentEntity.class.getName(), "c", SelectBuilder.NO_JOIN, null);
    hqlQuery.addFilter("AND", "cv.key = rc.key.parentContentVersionKey");
    hqlQuery.addFilter("AND", "c.mainVersion.key = cv.key");
    hqlQuery.addFilter(
        "AND",
        new InClauseBuilder<ContentKey>("rc.key.childContentKey", contentKeys) {
          public void appendValue(StringBuffer sql, ContentKey value) {
            sql.append(value.toString());
          }
        }.toString());

    hqlQuery.addFilter("AND", "c.deleted = 0");
    return hqlQuery.toString();
  }
コード例 #3
0
  private String getContentKeysHQL(
      ContentSpecification specification, String orderBy, boolean count) {
    final SelectBuilder hqlQuery = new SelectBuilder(0);

    if (count) {
      hqlQuery.addSelect("count (c.key) ");
    } else {
      hqlQuery.addSelect("c.key");
    }
    hqlQuery.addFromTable("ContentEntity", "c", SelectBuilder.NO_JOIN, null);

    applyIsDeletedFilter(specification, hqlQuery);

    applyAssignedToContentsHql(specification, hqlQuery);

    if (orderBy != null) {
      hqlQuery.addOrderBy(orderBy);
    }

    return hqlQuery.toString();
  }