Package org.hibernate.envers.tools.query

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


    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

        // 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

    }

    public void addIdsEqualToQuery(Parameters parameters, String prefix1, String prefix2) {
        List<QueryParameterData> paramDatas = mapToQueryParametersFromId(null);

        Parameters parametersToUse = getParametersToUse(parameters, paramDatas);

        for (QueryParameterData paramData : paramDatas) {
            parametersToUse.addWhere(paramData.getProperty(prefix1), false, "=", paramData.getProperty(prefix2), false);
        }
    }
View Full Code Here

    public void addIdsEqualToQuery(Parameters parameters, String prefix1, IdMapper mapper2, String prefix2) {
        List<QueryParameterData> paramDatas1 = mapToQueryParametersFromId(null);
        List<QueryParameterData> paramDatas2 = mapper2.mapToQueryParametersFromId(null);

        Parameters parametersToUse = getParametersToUse(parameters, paramDatas1);

        Iterator<QueryParameterData> paramDataIter1 = paramDatas1.iterator();
        Iterator<QueryParameterData> paramDataIter2 = paramDatas2.iterator();
        while (paramDataIter1.hasNext()) {
            QueryParameterData paramData1 = paramDataIter1.next();
            QueryParameterData paramData2 = paramDataIter2.next();

            parametersToUse.addWhere(paramData1.getProperty(prefix1), false, "=", paramData2.getProperty(prefix2), 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.