on ‎2024 May 27 7:08 PM
Hi Experts,
I'm working with RAP in BTP and have a question regarding UUIDs and semantic primary keys.
What is the best and recommended way to guarantee the uniqueness of a semantic primary key?
In RAP and OData V4, UUIDs provide us with the ability to create entities in draft mode without needing to validate the keys in the creation popup, which has limitations for more complex checking and responding with messages. Often, these validations result in the popup closing, causing the user to lose the data they have entered and forcing them to re-enter it.
I believe using automatically generated UUIDs allows us to move directly to the edit screen, where we have more control for validations and displaying messages without losing the input data.
I have two options already envisioned for helping me with this issue:
I'm looking forward to hear the input from the colleagues,
Jayme
Request clarification before answering.
Well, it looks like there is no easier way to do that. I tried to create a unique index in the table, but that only caused a dump and it is not handled by the framework and frontend. Additionally, there is no way to catch that problem in the RAP behavior class and transform it into a nice message (at least not in managed mode).
So my solution was to create a validation for checking the uniqueness of the Semantic Key.
I'll report my solution here for those who come after me:
Hope was helpfull for someone.
Cheers
ps: Thank you for the feedback @peterpersiel
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Peter,
Thank you for your response. Maybe I was not clear in the description. I'm talking about a table with related keys, not ones generating new records. For example, an Order Partners table where I have the key (Order/Partner Function/Partner), and I have to guarantee that the Partner appears only once for the same Order/Partner Function.
Hi colleagues,
sorry then I go the question wrong.
To answer the original question then: it sounds like uniqueness checks would have to be implemented, there is a precheck operation which can be use depending on the scenario - Uniqueness Check for Primary Keys
Regarding usage of Number Range Solution in RAP: Developing Early Unmanaged Numbering includes an example for numbering using Number Range solution
Best Regards,
Peter
| User | Count |
|---|---|
| 8 | |
| 7 | |
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.