diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java index 08ffd8802b91..74ab189a9bba 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/RoleDAOImpl.java @@ -2619,12 +2619,11 @@ private int getAudienceRefByID(String roleId, String tenantDomain) throws Identi int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); int refId; - try (Connection connection = IdentityDatabaseUtil.getDBConnection(false); + try (Connection connection = IdentityDatabaseUtil.getUserDBConnection(false); NamedPreparedStatement statement = new NamedPreparedStatement(connection, GET_AUDIENCE_REF_BY_ID_SQL)) { - statement.setInt(RoleConstants.RoleTableColumns.TENANT_ID, tenantId); - statement.setString(RoleConstants.RoleTableColumns.ATTR_NAME, RoleConstants.ID_URI); - statement.setString(RoleConstants.RoleTableColumns.ATTR_VALUE, roleId); + statement.setInt(RoleConstants.RoleTableColumns.UM_TENANT_ID, tenantId); + statement.setString(RoleConstants.RoleTableColumns.UM_UUID, roleId); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { refId = resultSet.getInt(1); @@ -2784,12 +2783,11 @@ public boolean isExistingRoleID(String roleId, String tenantDomain) throws Ident boolean isExist = false; int tenantId = IdentityTenantUtil.getTenantId(tenantDomain); - try (Connection connection = IdentityDatabaseUtil.getDBConnection(false); + try (Connection connection = IdentityDatabaseUtil.getUserDBConnection(false); NamedPreparedStatement statement = new NamedPreparedStatement(connection, IS_ROLE_ID_EXIST_SQL)) { - statement.setInt(RoleConstants.RoleTableColumns.TENANT_ID, tenantId); - statement.setString(RoleConstants.RoleTableColumns.ATTR_NAME, RoleConstants.ID_URI); - statement.setString(RoleConstants.RoleTableColumns.ATTR_VALUE, roleId); + statement.setInt(RoleConstants.RoleTableColumns.UM_TENANT_ID, tenantId); + statement.setString(RoleConstants.RoleTableColumns.UM_UUID, roleId); try (ResultSet resultSet = statement.executeQuery()) { if (resultSet.next()) { isExist = resultSet.getInt(1) > 0; diff --git a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/SQLQueries.java b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/SQLQueries.java index 202f65a7b211..101ac92a2246 100644 --- a/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/SQLQueries.java +++ b/components/role-mgt/org.wso2.carbon.identity.role.v2.mgt.core/src/main/java/org/wso2/carbon/identity/role/v2/mgt/core/dao/SQLQueries.java @@ -189,8 +189,8 @@ public class SQLQueries { "UM_HYBRID_ROLE INNER JOIN UM_HYBRID_ROLE_AUDIENCE ON UM_HYBRID_ROLE.UM_AUDIENCE_REF_ID = " + "UM_HYBRID_ROLE_AUDIENCE.UM_ID WHERE UM_HYBRID_ROLE.UM_UUID=:UM_UUID;"; - public static final String GET_AUDIENCE_REF_BY_ID_SQL = "SELECT AUDIENCE_REF_ID FROM IDN_SCIM_GROUP WHERE " + - "TENANT_ID=:TENANT_ID; AND ATTR_NAME=:ATTR_NAME; AND ATTR_VALUE=:ATTR_VALUE;"; + public static final String GET_AUDIENCE_REF_BY_ID_SQL = "SELECT UM_AUDIENCE_REF_ID FROM UM_HYBRID_ROLE WHERE " + + "UM_TENANT_ID=:UM_TENANT_ID; AND UM_UUID=:UM_UUID;"; public static final String ADD_IDP_GROUPS_SQL = "INSERT INTO UM_IDP_GROUP_ROLE (UM_ROLE_ID, UM_GROUP_ID, " + "UM_TENANT_ID) VALUES ((SELECT UM_ID FROM UM_HYBRID_ROLE WHERE UM_UUID=:UM_UUID; AND " + @@ -241,8 +241,8 @@ public class SQLQueries { public static final String GET_ROLE_NAME_BY_ID_SQL = "SELECT UM_ROLE_NAME FROM UM_HYBRID_ROLE WHERE " + "UM_TENANT_ID=:UM_TENANT_ID; AND UM_UUID=:UM_UUID;"; - public static final String IS_ROLE_ID_EXIST_SQL = "SELECT COUNT(ID) FROM IDN_SCIM_GROUP WHERE " - + "TENANT_ID=:TENANT_ID; AND ATTR_NAME=:ATTR_NAME; AND ATTR_VALUE=:ATTR_VALUE;"; + public static final String IS_ROLE_ID_EXIST_SQL = "SELECT COUNT(UM_ID) FROM UM_HYBRID_ROLE WHERE " + + "UM_TENANT_ID=:UM_TENANT_ID; AND UM_UUID=:UM_UUID;"; public static final String REMOVE_GROUP_FROM_ROLE_SQL = "DELETE FROM UM_HYBRID_GROUP_ROLE WHERE " + "UM_GROUP_NAME=:UM_GROUP_NAME; AND "