Using a numeric counter is better than using a timestamp. However, with an accurate time stamp, it is possible that two versions of the data can be captured at the same time and receive the same time stamp. Using a numerical counter (for example, update mytable set counter=counter+1, data=? where id=? and counter=? ), Each time the line changes, it gets a unique counter value. (Put the original value of the counter in the where clause, if the data has been changed by someone else, then no rows will be matched.)
Although this is not an βimplicitβ solution, I think that everything is in order. Libraries such as Hibernate have tools to let you do this kind of thing automatically, so your code should not worry about it.
source share