Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. compile ":mongodb:3.0.3"
  2. //runtime ":hibernate4:4.3.6.1"
  3.  
  4. environments {
  5. production {
  6. grails {
  7. mongo {
  8. replicaSet = [ "xxxxxxxx"]
  9. username = "xxxx"
  10. password= "xxxxxxxxxxxxxx"
  11. databaseName = "xxxxxx"
  12. }
  13. }
  14. }
  15. development {
  16. grails {
  17. mongo {
  18. replicaSet = [ "xxxxxxxx"]
  19. username = "xxxx"
  20. password= "xxxxxxxxxxxxxx"
  21. databaseName = "xxxxxx"
  22. }
  23. }
  24. }
  25. test {
  26. grails {
  27. mongo {
  28. replicaSet = [ "xxxxxxxx"]
  29. username = "xxxx"
  30. password= "xxxxxxxxxxxxxx"
  31. databaseName = "xxxxxx"
  32. }
  33. }
  34. }
  35. }
  36.  
  37. package test
  38.  
  39. class Book {
  40.  
  41. String name
  42. Map authors
  43. static hasMany = [authors:Author]
  44.  
  45. static constraints = {
  46. }
  47. }
  48.  
  49. package test
  50.  
  51. class Author {
  52.  
  53. String name
  54. static constraints = {
  55. }
  56. }
  57.  
  58. import test.*
  59.  
  60. def a = new Author(name:"Stephen King")
  61.  
  62. def book = new Book(name:"test")
  63. book.authors = ["stephen":a]
  64. book.save(failOnError:true)
  65.  
  66. {
  67. "_id": 1,
  68. "name": "test",
  69. "version": 0
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement