I have a generate method in one of my controllers that creates, updates and possibly destroys some ListColumns and ListCells, both of which have a list_id that points back to the original List. I need to ensure that the ListColumns won’t change while I’m creating the ListCells.
However, since generating the data might take a while, if a separate user calls generate on a different list, I’d like it to go ahead and create the ListColumns and ListCells for that list.
So, is there a way to lock the table so that I can’t add a ListColumn with a particular list_id until after the transaction is completed?
Thanks so much!
Use the
listtable rows themselves as locks. Simply select a row fromlistin exclusive mode:Even if you’re not going to actually update that row, doing that at the start of your method will block any other executions with the same
list_id