diff --git a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/constant/SQLConstants.java b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/constant/SQLConstants.java index abb99479..c29db410 100644 --- a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/constant/SQLConstants.java +++ b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/constant/SQLConstants.java @@ -359,6 +359,12 @@ public class SQLConstants { "UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_VALUE FROM UM_ORG INNER JOIN UM_ORG_ATTRIBUTE ON UM_ORG.UM_ID " + "= UM_ORG_ATTRIBUTE.UM_ORG_ID INNER JOIN (%s) AS FILTERED_ORG ON UM_ORG.UM_ID = FILTERED_ORG.UM_ID;"; + public static final String GET_ALL_UM_ORG_ATTRIBUTES_ORACLE = "SELECT UM_ORG.UM_ID, UM_ORG.UM_ORG_NAME, " + + "UM_ORG.UM_CREATED_TIME, UM_ORG.UM_STATUS, UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY, " + + "UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_VALUE FROM UM_ORG INNER JOIN UM_ORG_ATTRIBUTE ON UM_ORG.UM_ID " + + "= UM_ORG_ATTRIBUTE.UM_ORG_ID INNER JOIN (%s) FILTERED_ORG ON UM_ORG.UM_ID = FILTERED_ORG.UM_ID " + + "ORDER BY UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY"; + public static final String GET_ORGANIZATIONS_META_ATTRIBUTES = "SELECT DISTINCT " + "UM_ORG_ATTRIBUTE.UM_ATTRIBUTE_KEY FROM UM_ORG_ATTRIBUTE " + "JOIN UM_ORG ON UM_ORG_ATTRIBUTE.UM_ORG_ID = UM_ORG.UM_ID WHERE "; diff --git a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/dao/impl/OrganizationManagementDAOImpl.java b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/dao/impl/OrganizationManagementDAOImpl.java index ec508bea..891dbf99 100644 --- a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/dao/impl/OrganizationManagementDAOImpl.java +++ b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/dao/impl/OrganizationManagementDAOImpl.java @@ -142,6 +142,7 @@ import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.DELETE_ORGANIZATION_ATTRIBUTES_BY_ID; import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.DELETE_ORGANIZATION_BY_ID; import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ALL_UM_ORG_ATTRIBUTES; +import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ALL_UM_ORG_ATTRIBUTES_ORACLE; import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ANCESTORS_OF_GIVEN_ORG_INCLUDING_ITSELF; import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_ANCESTOR_ORGANIZATION_ID_WITH_DEPTH; import static org.wso2.carbon.identity.organization.management.service.constant.SQLConstants.GET_CHILD_ORGANIZATIONS; @@ -742,7 +743,11 @@ private List getOrganizationsList(boolean authorizedSubOrgsOnly, b boolean isFilteringMetaAttributes = filterQueryBuilder.getMetaAttributeCount() > 0; if (isFilteringMetaAttributes) { - sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES, sqlStmt); + if (isOracleDB()) { + sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES_ORACLE, sqlStmt); + } else { + sqlStmt = String.format(GET_ALL_UM_ORG_ATTRIBUTES, sqlStmt); + } } List organizations; Map organizationMap = new HashMap<>();