Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. class User {
  2. String name
  3.  
  4. static hasOne = [emailProfile: EmailProfile]
  5.  
  6. static constraints = {
  7. emailProfile unique: true, nullable: true
  8. }
  9. }
  10.  
  11. class EmailProfile {
  12. String email
  13. String password
  14.  
  15. static belongsTo = [user: User]
  16. }
  17.  
  18. new User(
  19. name: 'Bob',
  20. emailProfile: new EmailProfile(email: 'foo@bar.com', password: 'pass')
  21. ).save(failOnError: true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement