Package org.hibernate.envers.tools.query

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


    }

    public void addIdEqualsToQuery(Parameters parameters, Object id, String prefix, boolean equals) {
        List<QueryParameterData> paramDatas = mapToQueryParametersFromId(id);

        Parameters parametersToUse = getParametersToUse(parameters, paramDatas);

        for (QueryParameterData paramData : paramDatas) {
            if (paramData.getValue() == null) {
                handleNullValue(parametersToUse, paramData.getProperty(prefix), equals);
            } else {
                parametersToUse.addWhereWithParam(paramData.getProperty(prefix), equals ? "=" : "<>", paramData.getValue());
            }
        }
    }
View Full Code Here


    }

    public void addNamedIdEqualsToQuery(Parameters parameters, String prefix, boolean equals) {
        List<QueryParameterData> paramDatas = mapToQueryParametersFromId(null);

        Parameters parametersToUse = getParametersToUse(parameters, paramDatas);

        for (QueryParameterData paramData : paramDatas) {
            parametersToUse.addWhereWithNamedParam(paramData.getProperty(prefix), equals ? "=" : "<>", paramData.getQueryParameterName());
        }
    }
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

   * 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, String versionsMiddleEntityName,
                             QueryBuilder remQb, MiddleComponentData... componentData) {
    final Parameters disjoint = remQb.getRootParameters().addSubParameters( "or" );
    final Parameters valid = disjoint.addSubParameters( "and" ); // Restrictions to match all valid rows.
    final Parameters removed = disjoint.addSubParameters( "and" ); // Restrictions to match all rows deleted at exactly given revision.
    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" );
    final Parameters valid = disjoint.addSubParameters( "and" ); // Restrictions to match all valid rows.
    final Parameters removed = disjoint.addSubParameters( "and" ); // Restrictions to match all rows deleted at exactly given revision.
    // Excluding current revision, because we need to match data valid at the previous one.
    createValidDataRestrictions( globalCfg, auditStrategy, referencedIdData, remQb, valid, false );
    // 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

    qb.addProjection(
        "new list", MIDDLE_ENTITY_ALIAS + ", " + REFERENCED_ENTITY_ALIAS + ", " + INDEX_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

   * 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, String versionsMiddleEntityName,
                             QueryBuilder remQb, MiddleComponentData... componentData) {
    final Parameters disjoint = remQb.getRootParameters().addSubParameters( "or" );
    final Parameters valid = disjoint.addSubParameters( "and" ); // Restrictions to match all valid rows.
    final Parameters removed = disjoint.addSubParameters( "and" ); // Restrictions to match all rows deleted at exactly given revision.
    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 );
    // f.revision = :revision
    removed.addWhereWithNamedParam( INDEX_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 );
    // f.revision_type = DEL
    removed.addWhereWithNamedParam( INDEX_ENTITY_ALIAS + "." + revisionTypePropName, false, "=", DEL_REVISION_TYPE_PARAMETER );
  }
View Full Code Here

    public void addEntityAtRevisionRestriction(GlobalConfiguration globalCfg, QueryBuilder rootQueryBuilder,
      String revisionProperty,String revisionEndProperty, boolean addAlias,
            MiddleIdData idData, String revisionPropertyPath, String originalIdPropertyName,
            String alias1, String alias2) {
    Parameters rootParameters = rootQueryBuilder.getRootParameters();
    addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
  }
View Full Code Here

 
  public void addAssociationAtRevisionRestriction(QueryBuilder rootQueryBuilder,  String revisionProperty,
        String revisionEndProperty, boolean addAlias, MiddleIdData referencingIdData,
        String versionsMiddleEntityName, String eeOriginalIdPropertyPath, String revisionPropertyPath,
        String originalIdPropertyName, MiddleComponentData... componentDatas) {
    Parameters rootParameters = rootQueryBuilder.getRootParameters();
    addRevisionRestriction(rootParameters, revisionProperty, revisionEndProperty, addAlias);
  }
View Full Code Here

    private void addRevisionRestriction(Parameters rootParameters, 
      String revisionProperty, String revisionEndProperty, boolean addAlias) {
     
    // e.revision <= _revision and (e.endRevision > _revision or e.endRevision is null)
    Parameters subParm = rootParameters.addSubParameters("or");
    rootParameters.addWhereWithNamedParam(revisionProperty, addAlias, "<=", REVISION_PARAMETER);
    subParm.addWhereWithNamedParam(revisionEndProperty + ".id", addAlias, ">", REVISION_PARAMETER);
    subParm.addWhere(revisionEndProperty, addAlias, "is", "null", false);
  }
View Full Code Here

TOP

Related Classes of org.hibernate.envers.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.