May I know if you can suggest some ways for me to write a JDBC provisioning rule that can fulfil the following requirements? Thank you so much.
Here is my use case:
Role is a multi-value attribute and it is an entitlement.
When there is a new role granted to the user, I want to add an additional row to my DB.
When there is a role deleted, I want to delete that particular row.
Here is how my DC should look like:
UserID, FirstName, LastName, Email, Role
1001, Emily, Lee, [email protected], HR
1002, Eric, Chan, [email protected], Finance
1003, James, Bond, [email protected], Sales
1001, Emily, Lee, [email protected], Finance (<- this is the new role granted to Emily)
When a new role is granted to a user, an additional row should be added to the database. To achieve this, your table schema must allow multiple entries for the same UserID with different roles. Create a composite primary key or unique constraint on the combination of UserID and Role . The table schema should be as follows.
Thank you so much for your reply. I have tried it but the records seem to have some issue.
As shown in the image, when I add a new entitlement, the first name, last name and email value are null but a row with new role can be inserted into the db.
For the case of deleting one entitlement, it turns out that that particular row can be deleted. But the role value of other rows are set to be null as shown in the image.
May I know if you have any idea in fixing it? I do think your code makes perfect sense and really appreciate it. Thank you very much.
I have removed the first name, last name, email from add new entitlement plan. Now, you can add a new entitlement as per your requirement.
Regards to the delete entielement, primary key is combination of role and User ID in Table schema, . Can’t insert null into primary key field(Role).
Is there any business reason to set the Role to null? JDBC_Provisioning.java (4.8 KB)