I have field int displayOrder = 1 in Grails domain object and would like to increment it by 1 each time the domain object gets saved.
If I have domain object Widget that has one-to-many relationship with Pix, every time Widget gets a new Pix, Pix needs to have displayOrder incremented.
What would be the most prudent way of setting this up? Preferably count should start from 1 to keep confusion to minimum when someone wants to change the display order. I thought about just duplicating the ID, but then we are possibly looking at displayOrder of 1123, followed by 1169 , etc., so that's not a practical option.
The collection of Pixes belonging to Widget is a sortedSet.