Guest User

Untitled

a guest
Nov 15th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. class MyTable {
  2. Long revisionGroup
  3. Integer revisionNum = 1
  4.  
  5. ...
  6.  
  7. static constraints = {
  8. revisionGroup unique: 'revisionNum'
  9. }
  10. static mapping = {
  11. revisionGroup generator: 'auto'
  12. }
  13. }
  14.  
  15. //Save new data.
  16. MyTable myTable1 = new MyTable().save()
  17. //Do "soft update" of data by saving new revision.
  18. MyTable myTable2 = new MyTable(revisionGroup: myTable1.revisionGroup, revisionNum: myTable1.revisionNum + 1).save()
  19. //Save new data.
  20. MyTable myTable3 = new MyTable().save()
  21.  
  22. myTable1: id = 1, revisionGroup = 1, revisionNum = 1
  23. myTable2: id = 2, revisionGroup = 1, revisionNum = 2
  24. myTable3: id = 3, revisionGroup = 2, revisionNum = 1
Add Comment
Please, Sign In to add comment