Source:
<code>protected void addCriterionsToQuery(AuditReaderImplementor versionsReader) { if ( enversService.getEntitiesConfigurations().isVersioned( entityName ) ) { final EntityConfiguration entityConfig = enversService.getEntitiesConfigurations().get( entityName ); String auditEntityName = enversService.getAuditEntitiesConfiguration().getAuditEntityName( entityName ); Parameters joinConditionParameters = queryBuilder.addJoin( joinType, auditEntityName, alias, false ); AuditEntitiesConfiguration verEntCfg = enversService.getAuditEntitiesConfiguration(); final String originalIdPropertyName = verEntCfg.getOriginalIdPropName(); final String prefix = alias.concat( "." ).concat( originalIdPropertyName ); addOwnerReferenceIdentifierToTargetIdentifier( joinConditionParameters, entityConfig, prefix ); Parameters parametersToUse = parameters; String revisionPropertyPath = verEntCfg.getRevisionNumberPath(); <START> if (joinType == JoinType.LEFT) { <END> parametersToUse = parameters.addSubParameters( Parameters.OR ); parametersToUse.addNullRestriction( revisionPropertyPath, true ); parametersToUse = parametersToUse.addSubParameters( Parameters.AND ); } MiddleIdData referencedIdData = new MiddleIdData( verEntCfg, entityConfig.getIdMappingData(), null, entityName, true ); enversService.getAuditStrategy().addEntityAtRevisionRestriction( enversService.getGlobalConfiguration(), queryBuilder, parametersToUse, revisionPropertyPath, verEntCfg.getRevisionEndFieldName(), true, referencedIdData, revisionPropertyPath, originalIdPropertyName, alias, queryBuilder.generateAlias(), true ); } else { Parameters joinConditionParameters = queryBuilder.addJoin( joinType, entityName, alias, false ); addOwnerReferenceIdentifierToTargetIdentifier( joinConditionParameters, enversService.getEntitiesConfigurations().getNotVersionEntityConfiguration( entityName ), alias ); } super.addCriterionsToQuery( versionsReader ); }</code><technical_language>insert " "s for statement, super minor</technical_language>

Target:
protected void addCriterionsToQuery(AuditReaderImplementor versionsReader) { if ( enversService.getEntitiesConfigurations().isVersioned( entityName ) ) { final EntityConfiguration entityConfig = enversService.getEntitiesConfigurations().get( entityName ); String auditEntityName = enversService.getAuditEntitiesConfiguration().getAuditEntityName( entityName ); Parameters joinConditionParameters = queryBuilder.addJoin( joinType, auditEntityName, alias, false ); AuditEntitiesConfiguration verEntCfg = enversService.getAuditEntitiesConfiguration(); final String originalIdPropertyName = verEntCfg.getOriginalIdPropName(); final String prefix = alias + "." + originalIdPropertyName; addOwnerReferenceIdentifierToTargetIdentifier( joinConditionParameters, entityConfig, prefix ); Parameters parametersToUse = parameters; String revisionPropertyPath = verEntCfg.getRevisionNumberPath(); if ( joinType == JoinType.LEFT ) { parametersToUse = parameters.addSubParameters( Parameters.OR ); parametersToUse.addNullRestriction( revisionPropertyPath, true ); parametersToUse = parametersToUse.addSubParameters( Parameters.AND ); } MiddleIdData referencedIdData = new MiddleIdData( verEntCfg, entityConfig.getIdMappingData(), null, entityName, true ); enversService.getAuditStrategy().addEntityAtRevisionRestriction( enversService.getGlobalConfiguration(), queryBuilder, parametersToUse, revisionPropertyPath, verEntCfg.getRevisionEndFieldName(), true, referencedIdData, revisionPropertyPath, originalIdPropertyName, alias, queryBuilder.generateAlias(), true ); } else { Parameters joinConditionParameters = queryBuilder.addJoin( joinType, entityName, alias, false ); addOwnerReferenceIdentifierToTargetIdentifier( joinConditionParameters, enversService.getEntitiesConfigurations().getNotVersionEntityConfiguration( entityName ), alias ); } super.addCriterionsToQuery( versionsReader ); }