Package org.hibernate.envers.tools.query

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


        // SELECT new list(ee) FROM middleEntity ee
        QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee");
        qb.addFrom(referencedIdData.getAuditEntityName(), "e");
        qb.addProjection("new list", "ee, e", false, false);
        // WHERE
        Parameters rootParameters = qb.getRootParameters();
        // ee.id_ref_ed = e.id_ref_ed
        referencedIdData.getPrefixedMapper().addIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath,
                referencedIdData.getOriginalMapper(), "e." + originalIdPropertyName);
        // ee.originalId.id_ref_ing = :id_ref_ing
        referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true);

        // (selecting e entities at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addEntityAtRevisionRestriction(globalCfg, qb, "e." + revisionPropertyPath,
            "e." + verEntCfg.getRevisionEndFieldName(), false,
            referencedIdData, revisionPropertyPath, originalIdPropertyName, "e", "e2");

        // (with ee association at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addAssociationAtRevisionRestriction(qb, revisionPropertyPath,
            verEntCfg.getRevisionEndFieldName(), true, referencingIdData, versionsMiddleEntityName,
            eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas);

        // ee.revision_type != DEL
        rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), "!=", "delrevisiontype");
        // e.revision_type != DEL
        rootParameters.addWhereWithNamedParam("e." + verEntCfg.getRevisionTypePropName(), false, "!=", "delrevisiontype");

        StringBuilder sb = new StringBuilder();
        qb.build(sb, Collections.<String, Object>emptyMap());
        queryString = sb.toString();
    }
View Full Code Here


        // SELECT e FROM versionsEntity e
        QueryBuilder qb = new QueryBuilder(versionsReferencedEntityName, "e");
        qb.addProjection(null, "e", false, false);
        // WHERE
        Parameters rootParameters = qb.getRootParameters();
        // e.id_ref_ed = :id_ref_ed
        referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters, null, true);

        // (selecting e entities at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addEntityAtRevisionRestriction(globalCfg, qb, revisionPropertyPath,
            verEntCfg.getRevisionEndFieldName(), true, referencedIdData,
        revisionPropertyPath, originalIdPropertyName, "e", "e2");

        // e.revision_type != DEL
        rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), false, "!=", "delrevisiontype");

        StringBuilder sb = new StringBuilder();
        qb.build(sb, Collections.<String, Object>emptyMap());
        queryString = sb.toString();
    }
View Full Code Here

        // SELECT ee FROM middleEntity ee
        QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee");
        qb.addProjection(null, "ee", false, false);
        // WHERE
        Parameters rootParameters = qb.getRootParameters();
        // ee.originalId.id_ref_ing = :id_ref_ing
        referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true);
       
        String eeOriginalIdPropertyPath = "ee." + originalIdPropertyName;

        // (with ee association at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addAssociationAtRevisionRestriction(qb, revisionPropertyPath,
             verEntCfg.getRevisionEndFieldName(), true,referencingIdData, versionsMiddleEntityName,
             eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas);
        
        // ee.revision_type != DEL
        rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), "!=", "delrevisiontype");

        StringBuilder sb = new StringBuilder();
        qb.build(sb, Collections.<String, Object>emptyMap());
        queryString = sb.toString();
    }
View Full Code Here

        // SELECT new list(ee) FROM middleEntity ee
        QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee");
        qb.addFrom(referencedIdData.getEntityName(), "e");
        qb.addProjection("new list", "ee, e", false, false);
        // WHERE
        Parameters rootParameters = qb.getRootParameters();
        // ee.id_ref_ed = e.id_ref_ed
        referencedIdData.getPrefixedMapper().addIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath,
                referencedIdData.getOriginalMapper(), "e");
        // ee.originalId.id_ref_ing = :id_ref_ing
        referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true);

        // (with ee association at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addAssociationAtRevisionRestriction(qb, revisionPropertyPath,
            verEntCfg.getRevisionEndFieldName(), true,referencingIdData, versionsMiddleEntityName,
            eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas);

        // ee.revision_type != DEL
        rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), "!=", "delrevisiontype");

        StringBuilder sb = new StringBuilder();
        qb.build(sb, Collections.<String, Object>emptyMap());
        queryString = sb.toString();
    }
View Full Code Here

        QueryBuilder qb = new QueryBuilder(versionsMiddleEntityName, "ee");
        qb.addFrom(referencedIdData.getAuditEntityName(), "e");
        qb.addFrom(indexIdData.getAuditEntityName(), "f");
        qb.addProjection("new list", "ee, e, f", false, false);
        // WHERE
        Parameters rootParameters = qb.getRootParameters();
        // ee.id_ref_ed = e.id_ref_ed
        referencedIdData.getPrefixedMapper().addIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath,
                referencedIdData.getOriginalMapper(), "e." + originalIdPropertyName);
        // ee.id_ref_ind = f.id_ref_ind
        indexIdData.getPrefixedMapper().addIdsEqualToQuery(rootParameters, eeOriginalIdPropertyPath,
                indexIdData.getOriginalMapper(), "f." + originalIdPropertyName);
        // ee.originalId.id_ref_ing = :id_ref_ing
        referencingIdData.getPrefixedMapper().addNamedIdEqualsToQuery(rootParameters, originalIdPropertyName, true);

        // (selecting e entities at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addEntityAtRevisionRestriction(globalCfg, qb, "e." + revisionPropertyPath,
            "e." + verEntCfg.getRevisionEndFieldName(), false,
            referencedIdData, revisionPropertyPath, originalIdPropertyName, "e", "e2");
       
        // (selecting f entities at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addEntityAtRevisionRestriction(globalCfg, qb, "e." + revisionPropertyPath,
            "e." + verEntCfg.getRevisionEndFieldName(), false,
            referencedIdData, revisionPropertyPath, originalIdPropertyName, "f", "f2");

        // (with ee association at revision :revision)
        // --> based on auditStrategy (see above)
        auditStrategy.addAssociationAtRevisionRestriction(qb, revisionPropertyPath,
            verEntCfg.getRevisionEndFieldName(), true, referencingIdData, versionsMiddleEntityName,
            eeOriginalIdPropertyPath, revisionPropertyPath, originalIdPropertyName, componentDatas);

        // ee.revision_type != DEL
        rootParameters.addWhereWithNamedParam(verEntCfg.getRevisionTypePropName(), "!=", "delrevisiontype");
        // e.revision_type != DEL
        rootParameters.addWhereWithNamedParam("e." + verEntCfg.getRevisionTypePropName(), false, "!=", "delrevisiontype");
        // f.revision_type != DEL
        rootParameters.addWhereWithNamedParam("f." + verEntCfg.getRevisionTypePropName(), false, "!=", "delrevisiontype");

        StringBuilder sb = new StringBuilder();
        qb.build(sb, Collections.<String, Object>emptyMap());
        queryString = sb.toString();
    }
View Full Code Here

        criterions.add(criterion);
        return this;
    }

    public void addToQuery(AuditConfiguration verCfg, 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, entityName, qb, andParameters);
            }
        }
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");
    subParm.addWhereWithNamedParam(revisionEndProperty + ".id", addAlias, ">", "revision");
    subParm.addWhere(revisionEndProperty, addAlias, "is", "null", false);
  }
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();
   
    // create a subquery builder
        // SELECT max(e.revision) FROM versionsReferencedEntity e2
        QueryBuilder maxERevQb = rootQueryBuilder.newSubQueryBuilder(idData.getAuditEntityName(), alias2);
        maxERevQb.addProjection("max", revisionPropertyPath, false);
        // WHERE
        Parameters maxERevQbParameters = maxERevQb.getRootParameters();
        // e2.revision <= :revision
        maxERevQbParameters.addWhereWithNamedParam(revisionPropertyPath, "<=", REVISION_PARAMETER);
        // e2.id_ref_ed = e.id_ref_ed
        idData.getOriginalMapper().addIdsEqualToQuery(maxERevQbParameters,
                alias1 + "." + originalIdPropertyName, alias2 +"." + originalIdPropertyName);
   
    // add subquery to rootParameters
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.