code_junkie

Setting Grails domain id in Bootstrap.groovy

Nov 13th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. new Foo(id: 1234, name: "My Foo").save()
  2.  
  3. def foo = new Foo()
  4. foo.id = 1234
  5. foo.name = "My Foo"
  6. foo.save()
  7.  
  8. class Foo {
  9. String name
  10. static mapping = {
  11. id generator:'assigned'
  12. }
  13. }
  14.  
  15. class Foo {
  16. short code /* new field */
  17. String name
  18.  
  19. static constraints = {
  20. code(unique: true)
  21. name()
  22. }
  23. }
Add Comment
Please, Sign In to add comment