Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserProfile {
- String title
- String firstName
- String lastName
- static belongsTo = [user:User]
- static constraints = {
- user nullable:true , unique:true
- title nullable:true, blank:true
- firstName blank:false
- lastName nullable:true, blank:true
- }
- }
- class User {
- String username
- String password
- boolean enabled
- String email
- static constraints = {
- username size:6..40, blank:false, nullable: false, unique: true
- email email:true, size:6..40, blank:false, nullable: false, unique: true
- password size:5..64, password:true, blank:false, nullable: false
- }
- String toString(){username}
- }
- UserProfile.createCriteria().listDistinct({
- if(params.orderBy){
- if(params.orderBy=="email"){
- //the exception says that the element has no such property to both cases
- order("user.email", ascDesc)
- //order("email", ascDesc)
- }else{
- order("${params.orderBy}", ascDesc)
- }
- }
- })
- createAlias('user', 'u')
Add Comment
Please, Sign In to add comment