Primary Keys For Resources

Apparently, you can’t designate any arbitrary attribute as the resource identifier.  (At least, the model editor GUI does not support it.)  Rather, sMash just assumes the identifier will be an attribute called, “id”.

This became as issue when I tried to implement the delete and update services.  The sMash runtime should pass the identifier value in the calling URL for the web service.  e.g. http://localhost:8080/resources/personModel/12358983622.  That tells the web service which instance to act on. But before I added “id” to my resource model, the URL did not have any identifier value tacked on the end.

I took a number of steps to correct this problem so I don’t know which ones actually made the difference.  First, I added an attribute called “id” to the resource model.  Second, I ran the console command to generate the tables for this resource.  Third, I replaced the resource handler code with ZRM.delegate() and tested the application using the default relational persistence.  That worked.  And when I rewired the app to the custom handler that hooks to MDM Server, it still worked.  I don’t know whether generating the tables was actually necessary.

Leave a Reply

You must be logged in to post a comment.