私は次のスキームを持っています:
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
ユーザーがいるメールで注文したリストが必要です!
私は試します:
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)
}
}
})
そのため、メールで注文したい場合、例外は、両方のケースで要素にそのようなプロパティがないことを示しています。注:ascDesc
は変数String
であり、asc
またはdesc