Skip to content

Commit

Permalink
Fixed 'distinct' container queries for Oracle; TODO: sql server
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jun 30, 2017
1 parent f2d160b commit a8304da
Showing 1 changed file with 6 additions and 2 deletions.
Expand Up @@ -47,6 +47,7 @@
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationWorkItemType;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.Session;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -146,8 +147,11 @@ u.oid in (select distinct u.oid from RUser u where ...)
wrapperQuery.setResultTransformer(resultStyle.getResultTransformer());
wrapperQuery.addProjectionElementsFor(resultStyle.getIdentifiers(wrappedRootAlias));
wrapperQuery.addProjectionElementsFor(resultStyle.getContentAttributes(wrappedRootAlias));
wrapperQuery.getConditions().add(
wrapperQuery.createIn(wrapperQuery.getPrimaryEntityAlias() + ".oid", subqueryText));
List<String> inVariablesList = resultStyle.getIdentifiers(wrapperQuery.getPrimaryEntityAlias());
String inVariablesString = inVariablesList.size() != 1
? "(" + StringUtils.join(inVariablesList, ", ") + ")"
: inVariablesList.get(0);
wrapperQuery.getConditions().add(wrapperQuery.createIn(inVariablesString, subqueryText));
wrapperQuery.addParametersFrom(hibernateQuery.getParameters());
return wrapperQuery;
} else {
Expand Down

0 comments on commit a8304da

Please sign in to comment.