Guest User

Untitled

a guest
Feb 11th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. class UserProfile {
  2. String title
  3. String firstName
  4. String lastName
  5. static belongsTo = [user:User]
  6. static constraints = {
  7. user nullable:true , unique:true
  8. title nullable:true, blank:true
  9. firstName blank:false
  10. lastName nullable:true, blank:true
  11. }
  12. }
  13.  
  14. class User {
  15. String username
  16. String password
  17. boolean enabled
  18. String email
  19. static constraints = {
  20. username size:6..40, blank:false, nullable: false, unique: true
  21. email email:true, size:6..40, blank:false, nullable: false, unique: true
  22. password size:5..64, password:true, blank:false, nullable: false
  23. }
  24. String toString(){username}
  25. }
  26.  
  27. UserProfile.createCriteria().listDistinct({
  28. if(params.orderBy){
  29. if(params.orderBy=="email"){
  30. //the exception says that the element has no such property to both cases
  31. order("user.email", ascDesc)
  32. //order("email", ascDesc)
  33. }else{
  34. order("${params.orderBy}", ascDesc)
  35. }
  36. }
  37.  
  38. })
  39.  
  40. createAlias('user', 'u')
Add Comment
Please, Sign In to add comment