Package org.hibernate.envers.internal.tools.query

Examples of org.hibernate.envers.internal.tools.query.Parameters


        versionsMiddleEntityName,
        MIDDLE_ENTITY_ALIAS_DEF_AUD_STR
    );
    maxEeRevQb.addProjection( "max", revisionPropertyPath, false );
    // WHERE
    Parameters maxEeRevQbParameters = maxEeRevQb.getRootParameters();
    // ee2.revision <= :revision
    maxEeRevQbParameters.addWhereWithNamedParam( revisionPropertyPath, inclusive ? "<=" : "<", REVISION_PARAMETER );
    // ee2.originalId.* = ee.originalId.*
    String ee2OriginalIdPropertyPath = MIDDLE_ENTITY_ALIAS_DEF_AUD_STR + "." + originalIdPropertyName;
    referencingIdData.getPrefixedMapper().addIdsEqualToQuery(
        maxEeRevQbParameters,
        eeOriginalIdPropertyPath,
View Full Code Here


    );

    CriteriaTools.checkPropertyNotARelation( auditCfg, entityName, propertyName );

    // Make sure our conditions are ANDed together even if the parent Parameters have a different connective
    Parameters subParams = parameters.addSubParameters( Parameters.AND );
    // This will be the aggregated query, containing all the specified conditions
    QueryBuilder subQb = qb.newSubQueryBuilder();

    // Adding all specified conditions both to the main query, as well as to the
    // aggregated one.
    for ( AuditCriterion versionsCriteria : criterions ) {
      versionsCriteria.addToQuery( auditCfg, versionsReader, entityName, qb, subParams );
      versionsCriteria.addToQuery( auditCfg, versionsReader, entityName, subQb, subQb.getRootParameters() );
    }

    // Setting the desired projection of the aggregated query
    switch ( mode ) {
      case MIN:
        subQb.addProjection( "min", propertyName, false );
        break;
      case MAX:
        subQb.addProjection( "max", propertyName, false );
    }

    // Correlating subquery with the outer query by entity id. See JIRA HHH-7827.
    if ( correlate ) {
      final String originalIdPropertyName = auditCfg.getAuditEntCfg().getOriginalIdPropName();
      auditCfg.getEntCfg().get( entityName ).getIdMapper().addIdsEqualToQuery(
          subQb.getRootParameters(),
          subQb.getRootAlias() + "." + originalIdPropertyName,
          qb.getRootAlias() + "." + originalIdPropertyName
      );
    }

    // Adding the constrain on the result of the aggregated criteria
    subParams.addWhere( propertyName, "=", subQb );
  }
View Full Code Here

  }

  public void addToQuery(
      AuditConfiguration verCfg, AuditReaderImplementor versionsReader, String entityName,
      QueryBuilder qb, Parameters parameters) {
    Parameters andParameters = parameters.addSubParameters( Parameters.AND );

    if ( criterions.size() == 0 ) {
      andParameters.addWhere( "1", false, "=", "1", false );
    }
    else {
      for ( AuditCriterion criterion : criterions ) {
        criterion.addToQuery( verCfg, versionsReader, entityName, qb, andParameters );
      }
View Full Code Here

        entityName,
        propertyNameGetter
    );
    CriteriaTools.checkPropertyNotARelation( auditCfg, entityName, propertyName );

    Parameters subParams = parameters.addSubParameters( Parameters.AND );
    subParams.addWhereWithParam( propertyName, ">=", lo );
    subParams.addWhereWithParam( propertyName, "<=", hi );
  }
View Full Code Here

  }

  public void addToQuery(
      AuditConfiguration verCfg, AuditReaderImplementor versionsReader, String entityName,
      QueryBuilder qb, Parameters parameters) {
    Parameters opParameters = parameters.addSubParameters( op );

    lhs.addToQuery( verCfg, versionsReader, entityName, qb, opParameters.addSubParameters( "and" ) );
    rhs.addToQuery( verCfg, versionsReader, entityName, qb, opParameters.addSubParameters( "and" ) );
  }
View Full Code Here

    // SELECT new list(ee) FROM middleEntity ee
    QueryBuilder qb = new QueryBuilder( versionsMiddleEntityName, MIDDLE_ENTITY_ALIAS );
    qb.addFrom( referencedIdData.getAuditEntityName(), REFERENCED_ENTITY_ALIAS );
    qb.addProjection( "new list", MIDDLE_ENTITY_ALIAS + ", " + REFERENCED_ENTITY_ALIAS, false, false );
    // WHERE
    final Parameters rootParameters = qb.getRootParameters();
    // ee.id_ref_ed = e.id_ref_ed
    referencedIdData.getPrefixedMapper().addIdsEqualToQuery(
        rootParameters, eeOriginalIdPropertyPath, referencedIdData.getOriginalMapper(),
        REFERENCED_ENTITY_ALIAS + "." + originalIdPropertyName
    );
View Full Code Here

   */
  private void createValidAndRemovedDataRestrictions(
      GlobalConfiguration globalCfg, AuditStrategy auditStrategy,
      MiddleIdData referencedIdData, String versionsMiddleEntityName,
      QueryBuilder remQb, MiddleComponentData... componentData) {
    final Parameters disjoint = remQb.getRootParameters().addSubParameters( "or" );
    // Restrictions to match all valid rows.
    final Parameters valid = disjoint.addSubParameters( "and" );
    // Restrictions to match all rows deleted at exactly given revision.
    final Parameters removed = disjoint.addSubParameters( "and" );
    final String revisionPropertyPath = verEntCfg.getRevisionNumberPath();
    final String revisionTypePropName = getRevisionTypePath();
    // Excluding current revision, because we need to match data valid at the previous one.
    createValidDataRestrictions(
        globalCfg,
        auditStrategy,
        referencedIdData,
        versionsMiddleEntityName,
        remQb,
        valid,
        false,
        componentData
    );
    // ee.revision = :revision
    removed.addWhereWithNamedParam( revisionPropertyPath, "=", REVISION_PARAMETER );
    // e.revision = :revision
    removed.addWhereWithNamedParam(
        REFERENCED_ENTITY_ALIAS + "." + revisionPropertyPath,
        false,
        "=",
        REVISION_PARAMETER
    );
    // ee.revision_type = DEL
    removed.addWhereWithNamedParam( revisionTypePropName, "=", DEL_REVISION_TYPE_PARAMETER );
    // e.revision_type = DEL
    removed.addWhereWithNamedParam(
        REFERENCED_ENTITY_ALIAS + "." + revisionTypePropName,
        false,
        "=",
        DEL_REVISION_TYPE_PARAMETER
    );
View Full Code Here

   * Create query restrictions used to retrieve actual data and deletions that took place at exactly given revision.
   */
  private void createValidAndRemovedDataRestrictions(
      GlobalConfiguration globalCfg, AuditStrategy auditStrategy,
      MiddleIdData referencedIdData, QueryBuilder remQb) {
    final Parameters disjoint = remQb.getRootParameters().addSubParameters( "or" );
    // Restrictions to match all valid rows.
    final Parameters valid = disjoint.addSubParameters( "and" );
    // Restrictions to match all rows deleted at exactly given revision.
    final Parameters removed = disjoint.addSubParameters( "and" );
    // Excluding current revision, because we need to match data valid at the previous one.
    createValidDataRestrictions( globalCfg, auditStrategy, referencedIdData, remQb, valid );
    // e.revision = :revision
    removed.addWhereWithNamedParam( verEntCfg.getRevisionNumberPath(), false, "=", REVISION_PARAMETER );
    // e.revision_type = DEL
    removed.addWhereWithNamedParam( getRevisionTypePath(), false, "=", DEL_REVISION_TYPE_PARAMETER );
  }
View Full Code Here

   * Create query restrictions used to retrieve actual data and deletions that took place at exactly given revision.
   */
  private void createValidAndRemovedDataRestrictions(
      AuditStrategy auditStrategy, String versionsMiddleEntityName,
      QueryBuilder remQb, MiddleComponentData... componentData) {
    final Parameters disjoint = remQb.getRootParameters().addSubParameters( "or" );
    // Restrictions to match all valid rows.
    final Parameters valid = disjoint.addSubParameters( "and" );
    // Restrictions to match all rows deleted at exactly given revision.
    final Parameters removed = disjoint.addSubParameters( "and" );
    // Excluding current revision, because we need to match data valid at the previous one.
    createValidDataRestrictions( auditStrategy, versionsMiddleEntityName, remQb, valid, false, componentData );
    // ee.revision = :revision
    removed.addWhereWithNamedParam( verEntCfg.getRevisionNumberPath(), "=", REVISION_PARAMETER );
    // ee.revision_type = DEL
    removed.addWhereWithNamedParam( getRevisionTypePath(), "=", DEL_REVISION_TYPE_PARAMETER );
  }
View Full Code Here

    // SELECT new list(ee) FROM middleEntity ee
    final QueryBuilder qb = new QueryBuilder( versionsMiddleEntityName, MIDDLE_ENTITY_ALIAS );
    qb.addFrom( referencedIdData.getEntityName(), REFERENCED_ENTITY_ALIAS );
    qb.addProjection( "new list", MIDDLE_ENTITY_ALIAS + ", " + REFERENCED_ENTITY_ALIAS, false, false );
    // WHERE
    final Parameters rootParameters = qb.getRootParameters();
    // ee.id_ref_ed = e.id_ref_ed
    referencedIdData.getPrefixedMapper().addIdsEqualToQuery(
        rootParameters, eeOriginalIdPropertyPath, referencedIdData.getOriginalMapper(), REFERENCED_ENTITY_ALIAS
    );
    // ee.originalId.id_ref_ing = :id_ref_ing
View Full Code Here

TOP

Related Classes of org.hibernate.envers.internal.tools.query.Parameters

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.